10章作业(全)
import java.util.Scanner;
public class Bh {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int max = 9999;
int min = 1000;
String name = "Tom";
int password = 111111;
String as = "y";
int card = (int) (Math.random() * (max - min)) + min;
do {
System.out.println("******欢迎进入奖客富翁系统*****");
System.out.println(" 1.注册 ");
System.out.println(" 2.登录 ");
System.out.println(" 3.抽奖 ");
System.out.println("*****************************");
System.out.println("请选择菜单:");
int xz = input.nextInt();
if (xz == 1) {
System.out.println("[奖客富翁系统>注册]");
System.out.println("请填写个人注册信息:");
System.out.print("请输入用户名:");
name = input.next();
System.out.print("请输入密码:");
password = input.nextInt();
System.out.println(" \t");
System.out.println("注册成功,请记住您的会员卡卡号");
System.out.println("用户名 密码 会员卡号 ");
System.out
.println(name + " \t" + password + "\t " + card);
System.out.print("还要继续吗?(y/n)");
as = input.next();
} else if (xz == 2) {
System.out.println("[奖客富翁系统>登录]");
System.out.println("\t ");
for (int i = 1; i <= 3; i++) {
System.out.print("请输入用户名:");
String name1 = input.next();
System.out.print("请输入密码:");
int password2 = input.nextInt();
if (name.equals(name1) && password == password2) {
System.out.println("欢迎您:" + name1);
break;
} else {
System.out.println("请重新输入:");
}
}
System.out.print("还要继续吗?(y/n)");
as = input.next();
} else if (xz == 3) {
System.out.println("[奖客富翁系统>抽奖]");
System.out.print("请输入您的卡号:");
int kh = input.nextInt();
System.out.println("\t");
System.out.print("本日的幸运数字为:");
for (int i = 0; i < 3; i++) {
card = (int) (Math.random() * (max - min)) + min;
System.out.print(card + "\t");
}
if (kh == card) {
System.out.print("恭喜,您是今日的幸运会员!");
} else {
System.out.print("抱歉,您不是今日的幸运会员!");
}
System.out.print("还要继续吗?(y/n)");
as = input.next();
}
} while ("y".equals(as));
System.out.print("系统退出,谢谢使用!");
}
}