1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package 上机练习;
import java.util.Scanner;
public class A04class {
double Money = 0 ;
public double showA() {
return Money;
}
public void showB( double money) {
Money += money;
System.out.println( "当前余额:" + Money);
}
public void showC( double money2) {
if (money2 > Money) {
System.out.println( "余额不足!你当前称呼余额" + Money);
} else {
Money -= money2;
System.out.println( "取款成功" );
System.out.println( "当前余额:" + Money);
}
}
} package 上机练习;
import java.util.Scanner;
public class A04 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
A04class A04 = new A04class();
boolean con = true ;
while (con) {
System.out.println( "\t1.存 款 \t2.取 款 \t3.退 出" );
System.out.print( "请选择您要办理的业务:" );
int choice = in.nextInt();
switch (choice) {
case 1 :
System.out.print( "请输入存款金额:" );
double Money = in.nextDouble();
A04.showB(Money);
System.out.println( "存款成功" );
break ;
case 2 :
System.out.print( "请输入取款金额:" );
double Money2=in.nextInt();
A04.showC(Money2);
break ;
case 3 :
System.out.println( "谢谢使用!" );
con= false ;
break ;
default :
System.out.println( "输入有误!重新输入:" );
A04 A= new A04();
A.main( null );
break ;
}
}
}
} |
本文转自 Y幕徐 51CTO博客,原文链接:http://blog.51cto.com/765133133/1426606