标签:
1 package day01;
2 import java.util.Scanner;
3 public class Atm {
4
5 /**
6 * @param args
7 */
8 public static void main(String[] args) {
9 // TODO Auto-generated method stub
10 System.out.println("请输入密码");
11 Scanner con=new Scanner(System.in);
12 //用户从键盘中输入密码
13 String line=con.nextLine();
14 //如果密码等于1234
15 //java中字符串相等用equals比较
16 if(line.equals("1234")){
17 System.out.println("1、取款");
18 System.out.println("2、退出");
19 int num=con.nextInt();
20 switch(num){
21 case 1:
22 System.out.println("1、取款100");
23 System.out.println("2、取款200");
24 System.out.println("3、取款500");
25 System.out.println("4、其他");
26 int money=con.nextInt();
27 switch(money){
28 case 1:
29 System.out.println("取款100!");
30 case 2:
31 System.out.println("取款200!");
32 case 3:
33 System.out.println("取款500!");
34 case 4:
35 System.out.println("请输入金额!");
36 int other=con.nextInt();
37 System.out.println("取款:"+other+"元!");
38 break;
39 }
40 break;
41 case 2:
42 System.out.println("欢迎下次光临!退出!");
43 break;
44 }
45 }
46 }
47 }
标签:
原文地址:http://www.cnblogs.com/henrytien/p/4512985.html