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

    1

    package ffff;
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class Menu {
    
        
        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 :
                kanshu();
                break;
            case 5:
                System.out.println("退出");
                }
        }
    
        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("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);
            Random r= new Random();
            int a = input.nextInt();
            int b=r.nextInt(10);
            if(a/100%10==b){
                System.out.println("yes");
            }
            else{
                System.out.println("no");
            }
            returnMain();
            
        }
        public static void kanshu(){
            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("谢谢使用");
            }
    
        }
        
    
    }

    2 j阶乘

    package ffff;
    import java.util.*;
    public class jdjd {
             public static int jc(int a){
                int sum=1;
                for (int i = 1; i <=a; i++) {
                    sum*=i;
                }
                 return sum;
             }
             public static void main(String[] args) {
                Scanner input=new Scanner(System.in);
                int i=input.nextInt();
                System.out.println("阶乘是"+jc(i));
            }
    }

    3

    package ffff;
    import java.util.*;
    public class jdjd {
             public static void naian(int year){
                 if(year%4==0&&year%100==0||year%400==0){
                     System.out.println("yes");
                     
                 }
                 else{
                     System.out.println("no");
                 }
             
             }
             public static void main(String[] args) {
                Scanner input=new Scanner(System.in);
                System.out.println("输入年份");
                int i=input.nextInt();
                naian(i);
            }
    }
  • 相关阅读:
    灌溉 最小生成树
    queue的应用uva540
    大数相加
    对于jquery实现原理的浅谈
    div+CSS实现页面的布局要点记录
    spring注解注入的学习
    jsp内置对象学习记录
    web应用的乱码解决
    新发现:排序算法时间复杂度只有O(3n),命名为"wgw"排序法
    java编写的Http协议的多线程下载器
  • 原文地址:https://www.cnblogs.com/xxy02160216/p/12776863.html
Copyright © 2011-2022 走看看