2020.4.24
Posted yyyyym
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2020.4.24相关的知识,希望对你有一定的参考价值。
3.闰年
package ggd; import java.util.Scanner; public class jc { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int a=input.nextInt(); System.out.println("输入年份"); if(a%4==0&&a%100!=0||a%400==0){ System.out.println(a+"是闰年"); }else{ System.out.println(a+"不是闰年"); }} }
2.阶乘
package ggd; import java.util.Scanner; public class jc { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int a=input.nextInt(); int sum=1; for(int i=1;i<=a;i++){ sum=sum*i; System.out.println(a+"的阶乘为:"+sum); } }}
1
package leis; import java.util.Scanner; 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: abbMain(); break; case 3: cbbMain(); break; case 4: dbbMain(); break; case 5: ebbMain(); } } 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 returnMain(){ System.out.println("是否返回主菜单?Y/N"); Scanner input = new Scanner(System.in); if (input.next().equalsIgnoreCase("Y")) { mainMenu(); }else{ System.out.println("谢谢使用"); } } public static void abbMain(){ //注册 // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("注册"); System.out.println("注册用户名"); String u= input.next(); System.out.println("设置密码"); String ba = input.next(); if (u.equals("zs") && ba.equals("123")) { System.out.println("登录成功"); } else { System.out.println("登录失败"); } returnMain(); } public static void cbbMain(){ //抽奖 // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("幸运抽奖"); for(int m=0;m<=100;m++){ if(m==50){ System.out.println("恭喜中奖"); }else{ System.out.println("谢谢惠顾"); } } } public static void dbbMain(){ //看小故事 // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("看小故事"); returnMain(); } public static void ebbMain(){ // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("退出系统"); mainMenu(); }}
以上是关于2020.4.24的主要内容,如果未能解决你的问题,请参考以下文章