第八次

package Day01;
import java.util.Scanner;
import java.util.Random;
public class Lianxiti {

    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:
      register();
      break;
     case 2:
      login();
      break;
     case 3:
         cj();
      break;
     case 4:
      story();
      break;
     case 5:
      returnmain();
      break;
     }
    }
    public static void register() {
     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("123456")){
      System.out.println("登录成功");
     }else{
      System.out.println("登录失败");
     }
     returnmain();
    }
    public static void login(){
     Scanner input = new Scanner(System.in);
     System.out.println("注册姓名");
     String zname=input.next();
     System.out.println("注册密码");
     String zpwd=input.next();
     System.out.println("注册成功!");
     returnmain();
    }
    public static void cj(){
     Random r=new Random ();
     Scanner input=new Scanner(System.in);
     System.out.println("请输入四位会员号");
     int huiyuan=input.nextInt();
     int bai=huiyuan/100%10;
     int lucky=r.nextInt(10);
     if(bai==lucky){
      System.out.println("恭喜您,中奖了");
     }else{
      System.out.println("很抱歉,您不是幸运会员");
     }
     returnmain();
    }
    public static void story(){
      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("谢谢使用,再见");

    }
    }
复制代码

复制代码
package Day01;

public class Lianxiti {

    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 Day01;

public class Lianxiti{


        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 + "年不是闰年");
                    }

    }

}
复制代码

 

 
复制代码

 

 
复制代码
posted @ 2020-04-29 22:52  smile?  阅读(107)  评论(0编辑  收藏  举报