指导学习:幸运抽奖

指导学习:幸运抽奖

public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		
		int number = 0;
		String username = "";
		String password = "";
		String username2 = "";
		String password2 = "";
		int card = 0;
		
		//随机四位数生成
		int random = (int)(Math.random()*9000+1000);
		int random1 = (int)(Math.random()*9000+1000);
		int random2 = (int)(Math.random()*9000+1000);
		int random3 = (int)(Math.random()*9000+1000);
		int random4 = (int)(Math.random()*9000+1000);
		int random5 = (int)(Math.random()*9000+1000);
		//循环
		while(true){
			System.out.println("*****欢迎进入奖客富翁系统*****");
			System.out.println("\t1.注册");
			System.out.println("\t2.登陆");
			System.out.println("\t3.抽奖");
			System.out.println("************************");
			System.out.print("请选择菜单:");
			number = input.nextInt();
			
			switch(number){
			//选项1
			case 1 :
				System.out.println("[奖客富翁系统>注册]");
				System.out.println("请填写个人注册信息");
				System.out.print("用户名:");
				 username = input.next();
				System.out.print("密码:");
				 password = input.next();
				System.out.println("注册成功,请记好您的会员卡号");
				System.out.println("用户名\t密码\t会员卡号");
				System.out.println(username + "\t" + password + "\t" + random);
				break;
				//选项2
			case 2:
				System.out.println("[奖客富翁系统>登录]");
				for(int x = 1 ; x <= 3; x++){
					System.out.print("请输入用户名:");
					 username2 = input.next();
					System.out.print("请输入密码:");
					 password2 = input.next();
					if(username2.equals(username) && password2.equals(password) ){
						System.out.println("欢迎您:"+username);
						break;
					}else if((3-x)==0){
						System.out.println("您已经输入错了3次用户名和密码,系统退出,再见");
					}else{
						System.out.println("你还有"+(3-x)+"次机会,要珍惜哦!");
					}
				}
				break;
			case 3:
				System.out.println("[奖客富翁系统>抽奖]");
				System.out.println("请输入您的卡号:");
				card = input.nextInt();
				System.out.println();
				
				System.out.println("本日的幸运数字为:"+random1+"  "+ random2+"  " + random3+"  " + random4+"  " + random5);
				if(card  == random1 || card  == random1 || card  == random1 || card  == random1 || card  == random1){
					System.out.println("恭喜您,您是本日的幸运会员!");
				}else{
					System.out.println("抱歉!您不是本日的幸运会员!");
				}
				break;
				default :
					System.out.println("您输入有误,请重新输入");
					break;
			}
			System.out.println("继续吗?(y/n)");
			String number2 = input.next();
			if(number2.equals("n")){
				System.out.println("系统退出,谢谢使用!");
				break;
			}
		}
		
		
	}
	//喜欢小编的话就点个关注呗!
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值