题目
ATM取款
代码
Console.WriteLine("请输入密码:");
string mima = "111111";
int amount =0; for (int a = 0; a < 3; a++)
{
string shuru = Console.ReadLine();
if (shuru != mima)
{
Console.WriteLine("密码错误,请重新输入");
continue;
}
else
{
Console.WriteLine("请输入金额:");
amount =Convert.ToInt32(Console.ReadLine());
break;
}
}
for (int a = 0; a < 3; a++)
{
if (amount / 100 == 0 | amount < 0 | amount > 1000)
{
Console.WriteLine("你输入的金额不合法,请重新输入");
amount = Convert.ToInt32(Console.ReadLine());
continue;
}
else
{
Console.WriteLine("您取了{0}元", amount);
Console.WriteLine("交易完成,请取卡");
break;
}
}
Console.ReadKey();
网友评论