**银行取款案例**
-
package day1
-
import java.util.Scanner; // 导入外包中的类,类的地址
-
public class 条件语句 {
-
public static void main(String[] args) {
-
Scanner s = new Scanner(system.in);
-
// 创建一个Scanner类的对象 // Scanner s创建一个Scanner类型的变s // new Scanner(System.in)创建对象
-
int money = 500;
-
int count = 0;
-
while (true) {
-
if ( count == 3 ) {
-
System.out.println("密码已经输错三次,卡已锁定");
-
break;
-
}
-
System.out.println("请输入卡号");
-
int card = s.nextInt();
-
System.out.println("请输入密码");
-
int password = s.nextInt();
-
if( card==666 && password==111 ) {
-
System.out.println("请输入取款金额");
-
int m = s.nextInt();
-
if(m<money){
-
System.out.println("取款成功");
-
} else {
-
System.out.println("余额不足");
-
}
-
} else {
-
System.out.println("卡号或密码错误");
-
count++;
-
}
-
}
-
}
-
}