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

    1.

    package test;
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class LH {
    
        
        public static void main(String[] args) {
            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:
                zhuce();
                break;
            case 3:
                choujiang();
                break;
            case 4 :
                xiaogushi();
                break;
            case 5:
                System.out.println("退出");
                }
        }
    
        private static void login() {
            Scanner input = new Scanner(System.in);
            System.out.println("输入用户名");
            String uname = input.next();
            System.out.println("输入密码");
            String upwd = input.next();
            if (uname.equals("ltt") && upwd.equals("123")) {
                System.out.println("登录成功");
            } else {
                System.out.println("登录失败");
            }
            returnMain();
        
        }
        
        public static void zhuce(){
            Scanner input = new Scanner(System.in);
            System.out.println("输入用户名");
            String uname = input.next();
            System.out.println("输入密码");
            String upwd = input.next();
            System.out.println("注册成功");
            returnMain();
        }
        public static void choujiang() {
            Scanner input = new Scanner(System.in);
            System.out.println("抽奖模式");
            Random r=new Random();
            int sjs=r.nextInt(10);
            System.out.println("请输入四位会员数");
            int num=input.nextInt();
            if(num/100%10==sjs) {
                System.out.println("恭喜你,是幸运会员");
            }else {
                System.out.println("祝你下次好运");
            }
            returnMain();
        }
        public static void xiaogushi() {
            System.out.println("吃菠萝包的方法");
            System.out.println("1.张嘴");
            System.out.println("2.咬下去");
            System.out.println("3.扔皮");
            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("谢谢使用");
            }
    
        }
        
    
    }

    2.

    package test;
    public class LH {
            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));
            }
    }

    3.

    public class LH {
        public static void main(String[] args) {
            year(2020);
        }
    
        public static void year(int n){
            if (n%4==0&&n%100!=0||(n%400==0)){
                System.out.println(n+"是闰年");
            }else {
                System.out.println(n+"不是闰年");
            }
        }
    }
  • 相关阅读:
    寒假生活
    VS2010调试时修改代码 调试时源文件与模块生成时的文件不同
    如何在VS VC 中DLL使用CString类
    SVChost执行原理学习
    error LNK2001: unresolved external symbol __imp__PathFileExistsA@4
    visual studio 2010 遇到了异常,可能是由某个扩展导致的...
    C++运算各版本学习
    寒江独钓-键盘过滤学习2修改IDT + IOAPIC重定位表截获PS2键盘中断
    寒江独钓-键盘过滤学习1传统型的键盘过滤
    ObReferenceObjectByName 函数解析
  • 原文地址:https://www.cnblogs.com/z118127/p/12798087.html
Copyright © 2011-2022 走看看