import java.beans.beancontext.BeanContext;
import java.util.Scanner;
import java.util.logging.Handler;
public class lesson_10_homework {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int max = 9999;// 最大值
int min = 1000;// 最小值
int cardNumber = 0;// 用户银行
int lucynum;// 设置中奖码
int choose;// 选项
int pannum = 0;// 剩余次数
String rusername = null;// 用户名
String rpassword = null;// 密码
String loginword = null;// 登陆密码
String loginname = null;// 登陆用户名
boolean isReg = false;
boolean isLogin = false;// 登陆状态
boolean judge = false;
// 前台登陆系统
do {
System.out.println(" ");
System.out.println("*****欢迎进入奖客富翁系统*****");
System.out.println("\t1.注册");
System.out.println("\t2.登录");
System.out.println("\t3.抽奖");
System.out.println("****************************");
System.out.print("请选择菜单:");
choose = input.nextInt();
switch (choose) {
case 1:
System.out.println("[奖客富翁系统 > 注册]");
System.out.println("请填写个人注册信息:");
System.out.print("用户名:");
rusername = input.next();
System.out.print("密码:");
rpassword = input.next();
System.out.println("注册成功,请记好您的会员卡号");
System.out.println("用户名\t密码\t会员卡号");
cardNumber = (int) (Math.random() * (max - min)) + min;
System.out.println(rusername + "\t" + rpassword + "\t"
+ cardNumber);
isReg = true;
break;
case 2:
if (isReg == false) {
System.out.println("您还没有注册!");
continue;
} else if (isLogin == true) {
System.out.println("您已经登陆过了!");
} else {
System.out.println("[奖客富翁系统>登陆]");
System.out.print("用户名:");
loginname = input.next();
System.out.print("密码:");
loginword = input.next();
if (rusername.equals(loginname)
|| rpassword.equals(loginword)) {
System.out.println("欢迎您");
isLogin = true;
break;
} else {
while (pannum < 3) {
if (rusername.equals(loginname)
|| rpassword.equals(loginword)) {
System.out.println("欢迎您");
isLogin = true;
break;
} else {
System.out.println("用户名或密码错误,请重新输入");
System.out.println("[奖客富翁系统>登陆]");
System.out.print("用户名:");
loginname = input.next();
System.out.print("密码:");
loginword = input.next();
pannum++;
}
}
if (pannum == 3) {
System.out.println("退出系统");
System.exit(0);
}
}
}
break;
case 3:
if (isReg == false) {
System.out.println("您还没有注册!");
continue;
} else if (isLogin == false) {
System.out.println("您还没有登陆!");
} else {
System.out.print("今日幸运会员有:");
for (int i = 0; i < 4; i++) {
lucynum = (int) (Math.random() * (max - min)) + min;
System.out.print(lucynum + "\t");
if (cardNumber == lucynum) {
System.out.println("恭喜您中奖了!");
judge = true;
break;
}
}
}
break;
default:
continue;
}
} while (judge = true);
}
}
作业
最新推荐文章于 2021-05-05 00:21:27 发布