zoukankan      html  css  js  c++  java
  • 第八周作业

    package Wxte;
    import java.util.Random;
    import java.util.Scanner;
    
    public class Mast {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		mainMenu();
        }
        public static void mainMenu() {
            Scanner input = new Scanner(System.in);
            System.out.println("1.登录");
            System.out.println("2.注册");
            System.out.println("3.幸运抽奖,输入四位会员卡号,如果百位等于系统随机数,就是星运会员.否则不是.");
            System.out.println("4.看小故事,");
            System.out.println("5.退出系统");
            System.out.println("请选择");
            int i = input.nextInt();
            switch (i) {
            case 1:
                login();
                break;
            case 2:
                zc();
                break;
            case 3:
                xycj();
                break;
            case 4:
                kxgs();
                break;
            case 5:
                tc();
                break;
            }
        }
        private static void login() {
            // TODO Auto-generated method stub
            Scanner input = new Scanner(System.in);
            System.out.println("输入用户名");
            String uname = input.next();
            System.out.println("输入密码");
            String upwd = input.next();
            if (uname.equals("zs") && upwd.equals("234")) {
                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")) {
                mainMenu();
            }else{
                System.out.println("谢谢使用");
            }
        }
        private static void zc() {
            Scanner input = new Scanner(System.in);
            System.out.println("请输入用户名");
            String name = input.next();
            System.out.println("请输入密码");
            String mm = input.next();
            System.out.println("注册成功");
            returnMain();
        }
        private static void xycj() {
            Scanner input = new Scanner(System.in);
            System.out.println("请输入四位会员卡号");
            int x = input.nextInt();
            Random r = new Random();
            int a = r.nextInt(10);
            if (x / 10 % 10 == a) {
                System.out.println("恭喜你中奖啦!");
            } else {
                System.out.println("谢谢参与");
            }
            returnMain();
        }
        private static void kxgs() {
            Scanner input = new Scanner(System.in);
            System.out.println("请选择要看的故事:");
            System.out.println("1.丑小鸭");
            System.out.println("2.青蛙王子");
            int m = input.nextInt();
            switch(m) {
            case 1:
                System.out.println("丑小鸭");
                break;
            case 2:
                System.out.println("青蛙王子");
                break;
                returnMain();
            }
            private static void tc() {
                System.out.println("谢谢使用");
    	
    
    	}}
    

      

    package Wxte;
    import java.util.Scanner;
    
    public class Person {
    	  
        public static int Factorial(int x) {
            int sum = 1;
            for (int a = 1; a <= x; a++) {
                sum *= a;
            }
            return sum;
        }
        
        public static void main(String[] args) {
            System.out.println("请输入一个数字:");
            Scanner input = new Scanner(System.in);
            int i = input.nextInt();
            System.out.println(i + "的阶乘是:" + Factorial(i));
            
      
    }
    }
    

      

    package Wxte;
    import java.util.Random;
    import java.util.Scanner;
    
    public class Mast {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    	       prn(2020);
    	    }
    
    	    public static void prn(int year) {
    	        if (year%4==0&&year%100!=0||year%400==0) {
    	            System.out.println(year + "闰年");
    	        } else {
    	            System.out.println(year + "年不是闰年");
    	        }
    
    	    }
    	}
    

      

  • 相关阅读:
    Dirichlet distribution【转】
    实现Div层里的文字垂直居中的方法
    Kullback–Leibler divergence相对熵【转】
    判别模型、生成模型与朴素贝叶斯方法【转】
    卸载wine只需简单6个步骤【转】
    在ubuntu11.04通过Wine使用中国知网cnki的CAJview阅读器打开*.nh *.caj后缀的文献资料【转】
    网页制作学习网站收集
    XML数据绑定到Table中
    ubuntu10.04教育网更新源sources.list【转有效的】
    cidaemon.exe导致CPU100%的解决办法
  • 原文地址:https://www.cnblogs.com/575757ljp--/p/12786218.html
Copyright © 2011-2022 走看看