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
|
import
java.util.Scanner;
public
class
A05 {
/**
* @param args
*/
public
static
void
main(String[] args) {
// TODO Auto-generated method stub
Scanner input =
new
Scanner(System.in);
System.out.println(
"请输入消费金额:"
);
int
money = input.nextInt();
if
(money >=
50
) {
System.out.println(
"是否参加优惠换购活动:"
);
System.out.println(
"1.满50元,加2元换购百事可乐饮料1瓶"
);
System.out.println(
"2.满100,加3元换购500ml可乐一瓶"
);
System.out.println(
"2.满100,加10元换购5公斤面粉"
);
System.out.println(
"4.满200元,加10元换购苏泊尔炒锅一个"
);
System.out.println(
"5.满200元,加20元可换购欧莱雅爽肤水1瓶"
);
System.out.println(
"0.不换购"
);
System.out.print(
"请选择:"
);
int
choice = input.nextInt();
String show =
null
;
switch
(choice) {
case
1
:
show =
"百事可乐饮料1瓶"
;
money = money +
2
;
break
;
case
2
:
show =
"500ml可乐一瓶"
;
money = money +
3
;
break
;
case
3
:
show =
"5公斤面粉"
;
money = money +
10
;
break
;
case
4
:
money = money +
10
;
show =
"苏泊尔炒锅一个"
;
break
;
case
5
:
money = money +
20
;
show =
"欧莱雅爽肤水1瓶"
;
break
;
case
0
:
System.out.println(
"本次消费金额"
+money);
System.exit(
0
);
break
;
default
:
System.out.println(
"输入有误!程序异常结束!"
);
break
;
}
System.out.println(
"本次消费金额:"
+money+
"元"
);
System.out.println(
"成功换购,"
+show);
}
else
{
System.out.println(
"您的消费你符合活动条件!"
);
}
}
}
|
本文转自 Y幕徐 51CTO博客,原文链接:http://blog.51cto.com/765133133/1420172