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
|
import
java.util.Scanner;
public
class
A02 {
/**
* @param args
*/
public
static
void
main(String[] args) {
// TODO Auto-generated method stub
String admin =
null
, password =
null
, admin2, password2, choice2 =
null
;
int
random = (
int
) (Math.random() *
4000
);
int
random2[] =
new
int
[
4
];
do
{
Scanner input =
new
Scanner(System.in);
System.out.println(
"*******欢迎使用购物系统********"
);
System.out.println(
"\t\t1.注册"
);
System.out.println(
"\t\t2.登陆"
);
System.out.println(
"\t\t3.抽奖"
);
System.out.println(
"*****************************"
);
System.out.println(
"请选择菜单:"
);
int
choice = input.nextInt();
switch
(choice) {
case
1
:
System.out.println(
"购物管理系统>注册"
);
System.out.println(
"请输入用户名:"
);
admin = input.next();
System.out.println(
"请输入密码:"
);
password = input.next();
System.out.println(
"注册成功,请记好您的会员卡号"
);
System.out.println(
"用户名\t密码\t会员卡号"
);
System.out.println(admin +
"\t"
+ password +
"\t"
+ random);
break
;
case
2
:
System.out.println(
"购物管理系统>登陆"
);
System.out.println(
"请输入用户名:"
);
admin2 = input.next();
System.out.println(
"请输入密码:"
);
password2 = input.next();
if
(admin.equals(admin2) && password.equals(password2)) {
System.out.println(
"欢迎您"
+ admin);
}
else
{
System.out.println(
"用户名或密码错误!"
);
}
case
3
:
System.out.println(
"购物管理系统>抽奖"
);
System.out.println(
"请输入你的卡号<4位整数>:"
);
int
number = input.nextInt();
System.out.print(
"本日的幸运数字:"
);
for
(
int
i =
0
; i < random2.length; i++) {
random2[i] = (
int
) (Math.random() *
4000
);
System.out.print(random2[i] +
" "
);
}
for
(
int
i =
0
; i < random2.length; i++) {
if
(number == random2[i]) {
System.out.println(
"\n"
+
"恭喜你是幸运会员!"
);
break
;
}
else
{
System.out.println(
"\n抱歉您不是幸运会员!"
);
break
;
}
}
break
;
default
:
System.out.println(
"输入有误!重新输入!"
);
break
;
}
System.out.println(
"是否继续(y / n):"
);
choice2 = input.next();
}
while
(choice2.equals(
"y"
));
System.out.println(
"\n\n程序结束!"
);
}
}
|