• 第八周作业


    package bwk;
    
    import java.util.Random;
    import java.util.Scanner;
    public class Khdw {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            mainKhdw();
            } 
        
         
        public static void mainKhdw() {
            Scanner input = new Scanner(System.in);
            System.out.println("****************");
            System.out.println("   1. 登录");
            System.out.println("   2. 注册");
            System.out.println("   3.幸运抽奖");
            System.out.println("   4.看小故事");
            System.out.println("   5.退出系统");
            System.out.println("****************");
            System.out.print("请选择:");
            int i = input.nextInt();
            switch (i) {
            case 1:
                login();
                break;
            case 2:
                register();
                break;
            case 3:
                luck();
                break;
            case 4:
                story();
                break;
            case 5:
                exit();
                break;
            default:
                System.out.println("该系统暂未开放其它功能!");
                break;
            }
        }
     
        private static void login() {
            // TODO Auto-generated method stub
            Scanner input = new Scanner(System.in);
            System.out.print("请输入您的用户名:");
            String uname = input.next();
            System.out.print("请输入您的密码:");
            String upwd = input.next();
            if (uname.equals("zs") && upwd.equals("123")) {
                System.out.println("登录成功!");
            } else {
                System.out.println("登录失败");
            }
            returnMain();
     
        }
     
        public static void returnMain() {
            System.out.println("是否返回主菜单?Y/N");
            Scanner input = new Scanner(System.in);
            if (input.next().equalsIgnoreCase("Y")) {
                mainKhdw();
            } else {
                System.out.println("谢谢使用");
            }
     
        }
     
        public static void register() {
            Scanner input = new Scanner(System.in);
            System.out.print("请输入您的用户名:");
            String uname = input.next();
            System.out.print("请输入您的密码:");
            String upwd = input.next();
            System.out.println("您的账号已注册成功!!!");
            returnMain();
        }
     
        public static void luck() {
            System.out.println("**************************************欢迎来到幸运抽奖界面!*************************************");
            System.out.println(" *******规则为:如果您输入的四位会员卡号的百位等于系统随机数,您将成为我们的幸运会员,否则不是*******");
            Scanner input = new Scanner(System.in);
            int temp = 0;
            for (int i = 0;; i++) {
                System.out.print("请您输入四位的会员卡号:");
                int vipcard = input.nextInt();
                int bai = vipcard % 1000 / 100;
                temp = bai;
                if (vipcard < 999 || vipcard > 9999) {
                    System.out.println("您的会员卡号错误,请您重新输入!");
                } else {
                    break;
                }
            }
            Random r = new Random();
            int num = r.nextInt(9);
            System.out.println("系统生成的百位随机数为:" + num);
            if (num == temp) {
                System.out.println("恭喜您,成为我们的幸运会员!");
            } else {
                System.out.println("很遗憾,谢谢您的参与!");
            }
            returnMain();
        }
     
        public static void story() {
            System.out.println("欢迎您来到小故事界面,请您输入相应的数字(1-3)进行观看!");
            for (int i = 0;; i++) {
                Scanner input = new Scanner(System.in);
                int num = input.nextInt();
                switch (num) {
                case 1:
                    System.out.println("男儿事业多,何必学读书 —— 宋 · 张耒《阿几》");
                    break;
                case 2:
                    System.out.println("阿爷无大儿,木兰无长兄,愿为市鞍马,从此替爷征 —— 南北朝 · 佚名《木兰诗 / 木兰辞》");
                    break;
                case 3:
                    System.out.println("大儿荷锸去疏麻,小儿提筐来采茶,翁自決水灌秧芽 —— 宋 · 艾性夫《田家词》");
                    break;
                default:
                    System.out.println("您的输入有错,请重新输入!");
                }
                break;
            }
            returnMain();
        }
     
        public static void exit() {
            System.out.println("是否退出该系统?Y/N");
            Scanner input = new Scanner(System.in);
            if (input.next().equalsIgnoreCase("N")) {
                mainKhdw();
            } else {
                System.out.println("您已退出我们的系统,谢谢使用!");
            }
    
        }
    
    }

    package bwk;
    
    public class Khdw {
    
    
            // TODO Auto-generated method stub
             public static int jc(int a){
            int sum=1;
            for (int i = 1; i <=a; i++) {
                sum*=a;
                 
                 
            }
            return sum;
        }
        public static void main(String[] args) {
            System.out.println(jc(6));
        }
    }

    package bwk;
    
    public class Khdw {
    
    
            // TODO Auto-generated method stub
        public static void main(String[] args) {
            near(2020);
        }
            public static void near(int y){
                 if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) {
                        System.out.println(y + "年是闰年");
                    } else {
                        System.out.println(y + "年不是闰年");
                    }
            }
     
    }

  • 相关阅读:
    HDU
    矩形嵌套(DP)
    HDU
    HDU-1003 Max Sum
    Manacher算法—最长回文串
    Codeforces Round #460 (Div. 2) A B C D
    HDU 4540 威威猫系列故事——打地鼠 (简单DP)
    UVA 129 Krypton Factor(DFS 回溯)
    Codeforces 918A Eleven 918B Radio Station
    挑战程序设计竞赛(第2版)第112页勘误
  • 原文地址:https://www.cnblogs.com/bwk521/p/12792167.html
Copyright © 2020-2023  润新知