package exercise;
import java.util.Scanner;
public class Exe1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
//输入密码,循环
for (int i = 0 ; i < 3 ; i++){
System.out.println("请输入密码:");
int password = input.nextInt();
System.out.println(password);
//密码输入正确
if(password == 111111){
//输入金额
for (int j = 0 ; ;j++){
System.out.println("请输入金额(0~1000):");
int money = input.nextInt();
//金额不是100整数
if(money%100 != 0){
System.out.println("您输入的金额不合法,请重新输入:");
}
//金额为100整数
else{
if(money > 1000){
System.out.println("您输入的金额不合法,请重新输入:"+money);
}
else{
System.out.println("您取了"+money+"元");
System.out.println("交易完成,请取出卡片");
return;
}
}
}
}
//输入错误,继续for循环
else{
System.out.println("密码错误,您还剩"+(2-i)+"输入机会");
}
}
//密码三次错误
System.out.println("密码错误,请取卡");
}
}
![](https://images2015.cnblogs.com/blog/999165/201607/999165-20160728195627934-6958695.jpg)