import java.util.Scanner;
public class Test01 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		pw(sc);
		
	}
//	三次密码验证
	public static void pw(Scanner sc){
		boolean zh = false;
		boolean pw = false;
		int i = 3;
		while(i >0){
			System.out.println("您还有"+i+"次输入机会");
			System.out.println("请输入您的用户名");
			zh = sc.next().equals("admin");
			System.out.println("请输入您的密码");
			pw = sc.next().equals("20191225");
			i--;
			if(zh&&pw)
				break;
		}
		if(zh&&pw == true){
			zt(sc);
		}
	}
//	系统主体界面
	public static void zt(Scanner sc){
		String y = null;
		do {
			System.out.println("-------------欢迎admin进入系统-------------");
			System.out.println("1.计算梯形面积");
			System.out.println("2.求指定范围的素数");
			System.out.println("3.打印菱形");
			System.out.println("4.求指定范围的水仙花数");
			System.out.println("0.安全退出系统");
			System.out.println("---------@copyRight 2019-12-24 v1.0 高新管HP1904班所有---------");
			System.out.println("请输入您要选择的序号:");
			int a = sc.nextInt();
			if (a == 1) {
				mj(sc);
			}else if(a == 2){
				ss(sc);
			}else if (a ==3) {
				lx(sc);
			}else if (a == 4) {
				sxhs(sc);
			}else if(a == 0){
				System.out.println("您已选择退出,立即退出系统");
				break;
			}else{
				System.out.println("您的选择有误,请返回重新选择");
			}
			System.out.println("返回主菜单请按“Y”或者“y”");
			y = sc.next();
			
		} while (y.equals("Y")||y.equals("y"));
	}
//	梯形的面积
	public static void mj(Scanner sc){
//	梯形面积公式= (a+c)*h/2	
		System.out.println("请输入您的上底");
		int a = sc.nextInt();
		System.out.println("请输入您的下底");
		int c = sc.nextInt();
		System.out.println("请输入您的高");
		int h = sc.nextInt();
		System.out.println("您梯形的面积是:"+(a+c)*h/2);
	}
//	指定范围的素数
	public static void ss(Scanner sc){
		
	}
//	菱形
	public static void lx(Scanner sc){
		System.out.println("请输入菱形的行数");
		int arr =sc.nextInt();
		if(arr%2 == 0){
			System.out.println("您输入的是一个偶数,请重新选择");
		}else{
			int a = arr/2+1;
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < a-i; j++) {
					System.out.print(" ");
				}
				for (int j = 0; j < i; j++) {
					System.out.print("* ");
				}
				System.out.println();
			}
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < i; j++) {
					System.out.print(" ");
				}
				for (int j = 0; j < a-i; j++) {
					System.out.print("* ");
				}
				System.out.println();
			}
		}
	}
//	水仙花数
	public static void sxhs(Scanner sc){
		System.out.println("开始");
		int a = sc.nextInt();
		System.out.println("结束");
		int b = sc.nextInt();
		for (int i = a; i <= b; i++) {
			int gewei = i%10;
			int shiwei =i/10%10;
			int baiwei = i/100%10;
			int c = gewei*gewei*gewei+shiwei*shiwei*shiwei+baiwei*baiwei*baiwei;
			if(c == i){
				System.out.println(i+"是水仙花数");
			}
		}
	}
}
原文:https://www.cnblogs.com/weixin2623670713/p/13322053.html