package cn.jiit.test.day9;
import java.util.Scanner;
public class test5_2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int Password = 111111;
int password = 0; // 密码
int amount = 0;// 金额
int conut = 0;// 次数
boolean passWord = false;// 验证是否通过
while (conut < 3 && !passWord) {
System.out.println("请输入密码");
password = input.nextInt();
if (password != Password) {
conut++;
continue;
}
passWord = true;
System.out.println("请输入金额");
amount = input.nextInt();
while (amount > 0) {
if (amount % 100 == 0 && amount <= 1000) {
System.out.println("您取了" + amount + "元");
System.out.println("交易完成,请取卡");
break;
} else {
System.out.println("您输入的金额有误,请重新输入");
amount = input.nextInt();
continue;
}
}
}
if (!passWord) {
System.out.println("密码错误3次,退出系统,请取卡");
}
}
}
package cn.jiit.test.day9;
import java.util.Scanner;
public class test5 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int mima = 0;// 密码
int jine = 0;// 金额
int a = 0;// 输入密码次数
System.out.println("请输入密码");
mima = input.nextInt();
for (a = 3; a > 0; a--) {
if (mima == 111111) {
System.out.println("请输入金额");
jine = input.nextInt();
break;
} else {
System.out.println("密码错误,请重新输入");
mima = input.nextInt();
if (a == 1) {
System.out.println("输入密码错误3次,退出系统,请取回您的磁卡");
}
}
}
while (jine > 0) {
if (jine % 100 == 0 && jine <= 1000) {
System.out.println("您取了" + jine + "元");
System.out.print("交易完成,请取卡");
break;
} else {
System.out.println("您输入的金额有误,请重新输入:");
jine = input.nextInt();
continue;
}
}
}
}