• 幸运抽奖项目


    package java_Day10;
    
    import java.util.Scanner;
    
    public class LuckyNumbers {
        public static void main(String[] args) {
            // 判断是否继续
            String answer = "y";
            // 登录账号
            String logincode = "";
            // 登录密码
            String loginpassword = "";
            // 会员卡号
            int number = 0;
            //判断是否注册
            boolean isRight=false;
            //判断是否登录
            boolean islogin=false;
            Scanner input = new Scanner(System.in);
            do {
                System.out.println("******欢迎进入奖客富翁管理系统*******");
                System.out.println("		1.注册");
                System.out.println("		2.登录");
                System.out.println("		3.抽奖");
                System.out.println("请选择菜单:");
                int num = input.nextInt();
                switch (num) {
                case 1:
                    System.out.println(" [奖客富翁管理系统--注册]");
                    System.out.println("请填写个人注册信息");
                    System.out.println("用户名:");
                    logincode = input.next();
                    System.out.println("密码:");
                    loginpassword = input.next();
                    // 随机生成4位会员卡号
                    number = (int) (Math.random() * (9999 - 1000) + 1000);
                    System.out.println("注册成功,请记好您的会员卡号!");
                    System.out.println("用户名	密码	会员卡号");
                    System.out.println(logincode + "	" + loginpassword + "	"
                            + number);
                    isRight=true;
                    break;
                case 2:
                    if(isRight==true){
                        System.out.println(" [奖客富翁管理系统--登录]");
                        for (int i = 1; i <=3; i++) {
                            System.out.println("请输入用户名:");
                            String inputcode=input.next();
                            System.out.println("请输入密码:");
                            String inputpassowrd=input.next();
                            if(inputcode.equals(logincode)&&inputpassowrd.equals(loginpassword)){
                                System.out.println("欢迎您:"+logincode);
                                islogin=true;
                                break;
                            }else if(i<3){
                                System.out.println("您还有"+(3-i)+"次机会");
                                continue;
                            }else{
                                System.out.println("您没有机会了!");
                                break;
                            }
                        }
                        
                    }else{
                        System.out.println("您还没有注册,请注册之后再来登录!");
                    }
                    break;
                case 3:
                    if(islogin==true){
                        System.out.println(" [奖客富翁管理系统--登录]");
                        
                        for (int i = 1; i <=3; i++) {
                            System.out.println("请输入您的卡号:");
                            int kahao=input.nextInt();
                            if(number==kahao){
                                //随机数组
                                int [] numbers=new int[5];
                                
                                for (int j = 0; j < numbers.length; j++) {
                                    numbers[j]=(int) (Math.random() * (9999 - 1000) + 1000);
                                }
                                System.out.println("本期的幸运数字为:");
                                for (int j = 0; j < numbers.length; j++) {
                                    System.out.print(numbers[j]+"	");
                                    
                                }
                                //输入的幸运数字跟数组中的每一项比较
                                for (int j = 0; j < numbers.length; j++) {
                                    if(number==numbers[j]){
                                        System.out.print("中奖了!");
                                        break;
                                    }
                                    //j=4        numbers.length-1
                                    if(j==numbers.length-1){
                                        System.out.println("您不是本期幸运用户!");
                                    }
                                }
                                break;
                                
                            }else if(i<3){
                                System.out.println("您还有"+(3-i)+"次机会!");
                                continue;
                            }else{
                                System.out.println("您没有机会了!");
                                break;
                            }
                        }
                        
                    }else{
                        System.out.println("请先登录再来抽奖!");
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
                }
                System.out.println("继续吗?(y/n)");
                answer = input.next();
            } while ("y".equals(answer));
            if ("n".equals(answer)) {
                System.out.println("退出系统!");
            }
        }
    }
    package java_Day10;
    
    import java.util.Scanner;
    
    public class LuckyNumbers {
        public static void main(String[] args) {
            // 判断是否继续
            String answer = "y";
            // 登录账号
            String logincode = "";
            // 登录密码
            String loginpassword = "";
            // 会员卡号
            int number = 0;
            //判断是否注册
            boolean isRight=false;
            //判断是否登录
            boolean islogin=false;
            Scanner input = new Scanner(System.in);
            do {
                System.out.println("******欢迎进入奖客富翁管理系统*******");
                System.out.println("		1.注册");
                System.out.println("		2.登录");
                System.out.println("		3.抽奖");
                System.out.println("请选择菜单:");
                int num = input.nextInt();
                switch (num) {
                case 1:
                    System.out.println(" [奖客富翁管理系统--注册]");
                    System.out.println("请填写个人注册信息");
                    System.out.println("用户名:");
                    logincode = input.next();
                    System.out.println("密码:");
                    loginpassword = input.next();
                    // 随机生成4位会员卡号
                    number = (int) (Math.random() * (9999 - 1000) + 1000);
                    System.out.println("注册成功,请记好您的会员卡号!");
                    System.out.println("用户名	密码	会员卡号");
                    System.out.println(logincode + "	" + loginpassword + "	"
                            + number);
                    isRight=true;
                    break;
                case 2:
                    if(isRight==true){
                        System.out.println(" [奖客富翁管理系统--登录]");
                        for (int i = 1; i <=3; i++) {
                            System.out.println("请输入用户名:");
                            String inputcode=input.next();
                            System.out.println("请输入密码:");
                            String inputpassowrd=input.next();
                            if(inputcode.equals(logincode)&&inputpassowrd.equals(loginpassword)){
                                System.out.println("欢迎您:"+logincode);
                                islogin=true;
                                break;
                            }else if(i<3){
                                System.out.println("您还有"+(3-i)+"次机会");
                                continue;
                            }else{
                                System.out.println("您没有机会了!");
                                break;
                            }
                        }
                        
                    }else{
                        System.out.println("您还没有注册,请注册之后再来登录!");
                    }
                    break;
                case 3:
                    if(islogin==true){
                        System.out.println(" [奖客富翁管理系统--登录]");
                        
                        for (int i = 1; i <=3; i++) {
                            System.out.println("请输入您的卡号:");
                            int kahao=input.nextInt();
                            if(number==kahao){
                                //随机数组
                                int [] numbers=new int[5];
                                
                                for (int j = 0; j < numbers.length; j++) {
                                    numbers[j]=(int) (Math.random() * (9999 - 1000) + 1000);
                                }
                                System.out.println("本期的幸运数字为:");
                                for (int j = 0; j < numbers.length; j++) {
                                    System.out.print(numbers[j]+"	");
                                    
                                }
                                //输入的幸运数字跟数组中的每一项比较
                                for (int j = 0; j < numbers.length; j++) {
                                    if(number==numbers[j]){
                                        System.out.print("中奖了!");
                                        break;
                                    }
                                    //j=4        numbers.length-1
                                    if(j==numbers.length-1){
                                        System.out.println("您不是本期幸运用户!");
                                    }
                                }
                                break;
                                
                            }else if(i<3){
                                System.out.println("您还有"+(3-i)+"次机会!");
                                continue;
                            }else{
                                System.out.println("您没有机会了!");
                                break;
                            }
                        }
                        
                    }else{
                        System.out.println("请先登录再来抽奖!");
                    }
                    break;
                default:
                    System.out.println("输入错误,请重新输入");
                    break;
                }
                System.out.println("继续吗?(y/n)");
                answer = input.next();
            } while ("y".equals(answer));
            if ("n".equals(answer)) {
                System.out.println("退出系统!");
            }
        }
    }
  • 相关阅读:
    Cookie和Session机制详解
    MySQL数据库MyISAM和InnoDB存储引擎的比较
    MySQL索引背后的数据结构及算法原理
    Qt Meta Object System-元对象系统
    Qt事件处理机制
    学习STL-介绍一下STL
    为什么你有10年经验,但成不了专家?
    关于union的那些事儿
    关于enum的那些事儿
    三子棋局-挑战你的逻辑思维
  • 原文地址:https://www.cnblogs.com/yzwss/p/7411443.html
Copyright © 2020-2023  润新知