利用JAVA语言二重循环实现ATM机取款过程!

2024-11-26 20:43:21
推荐回答(2个)
回答1:

public static void main(String[] args) {
Scanner s, money;
int pass = 1111;
int tempass;
int choose = 0;
mkar: for (int i = 0; i < 3; i++) {
s = new Scanner(System.in);
money = new Scanner(System.in);
tempass = s.nextInt();
if (tempass == pass) {
for (;;) {
System.out.println("请输入1到9的数字选择你要取款的");
choose = money.nextInt();
switch (choose) {
case 1:
System.out.println("取款100");
break;
case 2:
System.out.println("取款200");
break;
case 3:
System.out.println("取款300");
break;
case 4:
System.out.println("取款400");
break;
case 5:
System.out.println("取款500");
break;
case 6:
System.out.println("取款600");
break;
case 7:
System.out.println("取款700");
break;
case 8:
System.out.println("取款800");
break;
case 9:
System.out.println("取款900");
break;
case 0:System.out.println("操作成功退出");
break mkar;
}
}
} else {
System.out.println("密码错误");
}
}
}
看下是不是你的要求,也可以自己改下

回答2:

出去,工作怎么样了,有时间打个电话回去