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
|
import
java.util.Scanner;
public
class
A02 {
/**
* @param args
*/
public
static
void
main(String[] args) {
// TODO Auto-generated method stub
Scanner input =
new
Scanner (System.in);
System.out.println(
"请输入月份:1~12"
);
int
choice=input.nextInt();
System.out.println(
"请问您是选择头等舱还是经济舱?头等舱输入1,经济舱输入2."
);
int
choice1=input.nextInt();
double
money=
0
;
if
(choice>=
4
&&choice<=
10
){
switch
(choice1) {
case
1
:
money=
5000
*
0.9
;
break
;
case
2
:
money=
5000
*
0.8
;
break
;
default
:
System.out.println(
"输入有误!"
);
break
;
}
}
else
{
switch
(choice1) {
case
1
:
money=
5000
*
0.5
;
break
;
case
2
:
money=
5000
*
0.4
;
break
;
default
:
System.out.println(
"输入有误!"
);
break
;
}
}
System.out.println(
"您的机票价格为:"
+money);
}
}
|
本文转自 Y幕徐 51CTO博客,原文链接:http://blog.51cto.com/765133133/1420175