幸运客户抽奖

import java.util.Scanner;
public class LuckyDraw {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int choice;
        String isGoOn;
        String userName = "";
        String inName;
        int userSecreat = 0;
        int inSecreat;
        int userNo = 0;
        int inNo;
        boolean flagRegister = false;
        boolean flagLogin = false;
        boolean isLucky = false;

        do {System.out.println("* * * * * 欢迎进入奖客富翁系统 * * * * *");
            System.out.println("\t\t\t1.注册");
            System.out.println("\t\t\t2.登陆");
            System.out.println("\t\t\t3.抽奖");
            System.out.println("* * * * * * * * * * * * * * * * * * * *");
            System.out.print("请选择菜单:");
            choice = in.nextInt();
            switch (choice){
                case 1:
                    System.out.println("[奖客富翁系统 > 注册]");
                    System.out.println("请填写个人注册信息:");
                    System.out.println("用户名:");
                    userName = in.next();
                    System.out.println("密码:");
                    userSecreat = in.nextInt();
                    System.out.println("");
                    userNo = (int)(Math.random()*(9999-1000))+1000;
                    System.out.println("注册成功,请记好您的会员卡号");
                    System.out.println("用户名\t密码\t会员卡号");
                    System.out.println(userName + "\t" + userSecreat + "\t" + userNo);
                    flagRegister = true;
                    break;
                case 2:
                    System.out.println("[奖客富翁系统 > 登陆]");
                    if(flagRegister){
                        for (int i = 0; i < 3; i++) {
                            System.out.println("请输入用户名:");
                            inName = in.next();
                            System.out.println("请输入密码:");
                            inSecreat = in.nextInt();
                            if(userName.equals(inName) && userSecreat == inSecreat){
                                System.out.println("");
                                System.out.println("欢迎您:" + userName);
                                flagLogin = true;
                                break;
                            }
                            System.out.println("用户名和密码错误!");
                            System.out.println("您还有" + (3-i-1) + "次机会!");
                        }
                    }else {
                        System.out.println("请您先注册!");
                    }
                    break;
                case 3:
                    System.out.println("[奖客富翁系统 > 抽奖]");
                    if(flagLogin){
                        while(true){
                            System.out.println("请输入您的卡号:");
                            inNo = in.nextInt();
                            if(userNo != inNo){
                                System.out.println("该卡号不存在,请重新输入!");
                                continue;
                            }
                            break;
                        }
                        System.out.println("");
                        System.out.println("本日的幸运数字为:");
                        int[] luckyNum = new int[4];
                        for (int i = 0; i < luckyNum.length; i++) {
                            luckyNum[i] = (int)(Math.random()*(9999-1000))+1000;
                            System.out.print(luckyNum[i] +"\t");
                            if(luckyNum[i] == userNo){
                                isLucky = true;
                            }
                        }
                        System.out.println("");
                        if(isLucky){
                            System.out.println("恭喜!您是本日的幸运会员!");
                        }else{
                            System.out.println("抱歉!您不是本日的幸运会员!");
                        }
                        System.out.println("");
                    }else {
                        System.out.println("请您先登录!");
                    }
                    break;
                default:
                    System.out.println("您的输入有误!");
                    break;
            }
            System.out.print("继续吗?(y/n):");
            isGoOn = in.next();
        }while("y".equals(isGoOn));

        System.out.println("");
        System.out.println("系统退出,谢谢使用!");
    }
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值