作业

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);

	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值