import java.util.Scanner;
public class Zlianxi72926 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("\tATM取款业务");
System.out.println("插上卡后请输入密码:");
int password = input.nextInt();
int k = 0;
int sum = 0;
int amount = 0;
for (int i = 0; i < 3; i++) {
if (password != 111111) {
System.out.println("请重新输入:");
k++;
if (k == 3) {
System.out.println("密码错误,请取卡!!");
return;
}
password = input.nextInt();
} else {
break;
}
}
x2: while (true) {
System.out.println("请选择金额,请输入0到6中任意数字选择对应钱数!");
System.out.println("0.——手动输入金额\n1.——100元\n2.——300元\n3.——500元\n4.——1000元\n5.——3000元\n6.——5000元");
int num = input.nextInt();
String jx;
x1: while (true) {
switch (num) {
case 0:
break x1;
case 1:
amount = 100;
sum += amount;
break;
case 2:
amount = 300;
sum += amount;
break;
case 3:
amount = 500;
sum += amount;
break;
case 4:
amount = 1000;
ATM取款机循环和选择语句,两种方式。
最新推荐文章于 2022-07-23 22:53:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)