• 第八次作业



    package
    dfishf; import java.util.Random; import java.util.Scanner; public class homework { 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 n = input.nextInt(); switch (n) { case 1: login(); break; case 2: zc(); break; case 3: cj(); break; case 4: story(); break; case 5: tc(); break; } } public static void tc() { System.out.println("谢谢使用"); } public static void story() { Scanner input = new Scanner(System.in); System.out.println("请选择想看的故事"); System.out.println("1.jojo1"); System.out.println("2.jojo2"); System.out.println("3.jojo3"); int a = input.nextInt(); switch (a) { case 1: System.out.println("大乔揍dio"); break; case 2: System.out.println("二乔揍阿姨压一压"); break; case 3: System.out.println("三桥继续揍dio"); break; } returnMain(); } private static void choujiang() { Scanner input = new Scanner(System.in); System.out.println("请输入四位会员卡号"); int x = input.nextInt(); Random r = new Random(); int a = r.nextInt(10); if (x / 100 % 10 == a) { System.out.println("恭喜你中奖啦!"); } else { System.out.println("谢谢参与"); } returnMain(); } private static void zhuce() { Scanner input = new Scanner(System.in); System.out.println("请输入用户名"); String name = input.next(); System.out.println("请输入密码"); String mima = input.next(); System.out.println("注册成功"); returnMain(); } 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("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")) { Mainmenu(); } else { System.out.println("谢谢使用"); } } }

    1.完善menu注册功能,抽奖,看小故事等功能

    package dfishf;
    
    public class homework {
    
        public static void main(String[] args) {
              jiecheng p=new jiecheng();
                p.method(5);
            }
            public void method(int a) {
                int b=1;
                for(int i=1;i<=a;i++) {
                    b*=i;
                }
                a=b;
                System.out.println(a);
            }
        
    }

     2编写一个方法,求整数n的阶乘,例如5的阶乘是1*2*3*4*5

    package dfishf;
    
    public class homework{
        public static void main(String[] args) {
            prn(2018);
        }
    
        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 + "不是闰年");
            }
    
        }
    }

    3.编写一个方法,判断该年份是平年还是闰年

  • 相关阅读:
    野路子码农系列(7)近期花里胡哨技巧汇总
    野路子码农系列(6)有关线下验证集选取的思考
    野路子码农(5)Python中的装饰器,可能是最通俗的解说
    野路子码农(4)挖掘机云端部署小试
    野路子码农系列(3)plotly可视化的简单套路
    野路子码农系列(2)Python中的类,可能是最通俗的解说
    野路子码农系列(1) 创建Web API
    pandas技巧两则——列内元素统计和列内元素排序
    Windows环境下Anaconda安装TensorFlow的避坑指南
    让米帝领事馆给你报空气质量(动态网页爬取及简单的数据整理)
  • 原文地址:https://www.cnblogs.com/reddead/p/12796621.html
Copyright © 2020-2023  润新知