三章

	private static void j3_1() {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		int n = i % 2;
		if (n == 0) {
			System.out.println("N是偶数");
		} else
			System.out.println("N是奇数");
	}

	private static void j3_2() {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		switch (i) {
		case (1):
			System.out.println(1);
			break;
		case (5):
			System.out.println(5);
			break;
		case (10):
			System.out.println(10);
			break;
		default:
			System.out.println("none");
			break;
		}
	}

	private static void j3_3() {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		if (i % 5 == 0 && i % 6 == 0) {
			System.out.println("同时整除");
		} else if (i % 5 == 0 && i % 6 != 0) {
			System.out.println("只能5");
		} else if (i % 5 != 0 && i % 6 == 0) {
			System.out.println("只能6");
		} else
			System.out.println("都不能");
	}

	private static void j3_4() {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		if ((x % 4 == 0 && x % 100 != 0) || x % 400 == 0) {
			System.out.println(x + "是闰年");
		} else
			System.out.println(x + "年不是闰年");
	}

	private static void j3_5() {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		if (x < 0 || x > 100) {
			System.out.println("分数无效");
		} else if (x < 60) {
			System.out.println("E");
		} else if (x < 70) {
			System.out.println("D");
		} else if (x < 80) {
			System.out.println("C");
		} else if (x < 90) {
			System.out.println("B");
		} else {
			System.out.println("A");
		}
	}

	private static void j3_6() {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		int y = s.nextInt();
		int z = s.nextInt();
		int temp;
		if (x > y) {
			temp = y;
			y = x;
			x = temp;
		}
		if (y > z) {
			temp = y;
			y = z;
			z = temp;
		}
		if (x > y) {
			temp = y;
			y = x;
			x = temp;
		}
		System.out.println(x + "," + y + "," + z);
	}

	private static void j3_8() {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();

		if (x > 99999 || x < 0) {
			System.out.println("超出范围");
		}
		if (x >= 0 && x < 10) {
			System.out.println("一位数");
		}
		if (x >= 10 && x < 100) {
			System.out.println("二位数");
		}
		if (x >= 100 && x < 1000) {
			System.out.println("三位数");
		}
		if (x >= 1000 && x < 10000) {
			System.out.println("四位数");
		}
		if (x >= 10000 && x < 1000000) {
			System.out.println("五位数");
		}
		System.out.print("输如的数位依次是:");
		while (x > 0) {
			int n = 0;
			n = x % 10;
			x /= 10;
			System.out.print(n + "\t");
		}
	}

	private static void j3_9() {
		Scanner sc = new Scanner(System.in);
		double x = sc.nextDouble();
		double s = 1;
		if (x < 100) {
			s = 1;
		}
		if (x > 100 && x < 5000) {
			s = x * 0.01;
		}
		if (x > 5000) {
			s = 50;
		}
		System.out.println(s);
	}

	private static void j3_10() {
		System.out.println("输入当月利润:(单位:万元)");
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		System.out.print("提成为:");
		if (a < 10) {
			System.out.println(a * 0.1);
		}
		if (a >= 10 && a < 20) {
			System.out.println((a - 10) * 0.75 + 10 * 0.1);
		}
		if (a >= 20 && a < 40) {
			System.out.println((a - 20) * 0.05 + 10 * 0.075 + 10 * 0.1);
		}
		if (a >= 40 && a < 60) {
			System.out.println((a - 40) * 0.03 + 20 * 0.05 + 10 * 0.075 + 10
					* 0.1);
		}
		if (a >= 60 && a < 100) {
			System.out.println((a - 60) * 0.015 + 20 * 0.03 + 20 * 0.05 + 10
					* 0.075 + 10 * 0.1);
		}
		if (a >= 100) {
			System.out.println((a - 100) * 0.01 + 40 * 0.015 + 20 * 0.03 + 20
					* 0.05 + 10 * 0.075 + 10 * 0.1);
		}
	}

	private static void j3_11() {
		// for
		int sum1 = 0;
		for (int i = 1; i <= 100; i++) {
			if (i % 3 == 0) {
				sum1 += i;
			}
		}
		System.out.println(sum1);
		// while
		int sum2 = 0;
		int i = 1;
		while (i <= 100) {
			if (i % 3 == 0) {
				sum2 += i;
			}
			i++;
		}
		System.out.println(sum2);
		// do-while
		int sum3 = 0;
		int i1 = 0;
		do {
			if (i1 % 3 == 0) {
				sum3 += i1;
			}
			i1++;
		} while (i1 <= 100);
		System.out.println(sum3);
	}

	private static void j3_12() {
		for (int i = 0; i <= 9; i++) {
			if (i != 5) {
				System.out.print(i + "\t");
			}
		}
	}

	private static void j3_13() {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		s = s / 10;
		switch (s) {
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
			System.out.println("E");
			break;
		case 6:
			System.out.println("D");
			break;
		case 7:
			System.out.println("C");
			break;
		case 8:
			System.out.println("B");
			break;
		case 9:
		case 10:
			System.out.println("A");
			break;
		default:
			System.out.println("ERROR");
		}
	}

	private static void j3_14() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 1;
		for (int i = 1; i <= n; i++) {
			sum *= i;
		}
		System.out.println(sum);
	}

	private static void j3_15() {
		boolean rzt = false;
		for (int n = 200; !rzt; n++) {
			int i = 2;
			rzt = true;
			while (rzt && i < n) {
				if ((n % i) == 0) {
					rzt = false;
					i++;
				}
			}
			System.out.println("n=" + (n + 1));
		}
	}

	private static void j3_16() {
		// 16
		java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");// 将输入结果精确到小数点后两位
		double sal = 30000;
		for (int i = 0; i < 10; i++) {
			sal *= (1 + 0.06);
			System.out.println((i + 1) + "年后的工资为" + df.format(sal) + "元");
		}
	}

	private static void j3x_1() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int max, min, mid = 0;

		min = (a < b ? a : b) < c ? (a < b ? a : b) : c;

		max = (a > b ? a : b) > c ? (a > b ? a : b) : c;

		if (a == max && b == min || a == min && b == max) {
			mid = c;
		}
		if (a == max && c == min || a == min && c == max) {
			mid = b;
		}
		if (b == max && c == min || c == max && b == min) {
			mid = a;
		}

		System.out.println("最小值为" + min);
		System.out.println("中间值为" + mid);
		System.out.println("最大值为" + max);
	}

	private static void j3x_2() {
		// j3x_2
		System.out.println("输入年 月 日:(以空格分开)");
		Scanner sc = new Scanner(System.in);
		int y = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();
		int eryue, tianshu = 0;

		if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {
			eryue = 29;
		} else {
			eryue = 28;
		}

		switch (m) {
		case 1:
			tianshu = d;
			break;
		case 2:
			tianshu = d + 31;
			break;
		case 3:
			tianshu = d + 31 + eryue;
			break;
		case 4:
			tianshu = d + 31 + eryue + 31;
			break;
		case 5:
			tianshu = d + 31 + eryue + 31 + 30;
			break;
		case 6:
			tianshu = d + 31 + eryue + 31 + 30 + 31;
			break;
		case 7:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30;
			break;
		case 8:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30 + 31;
			break;
		case 9:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30 + 31 + 31;
			break;
		case 10:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30 + 31 + 31 + 30;
			break;
		case 11:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
			break;
		case 12:
			tianshu = d + 31 + eryue + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31
					+ 30;
			break;

		}
		System.out.println(y + "年" + m + "月" + d + "日是当年的第" + tianshu + "天");
	}

	private static void j3x_3() {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[4];
		for (int i = 0; i < 4; i++) {
			a[i] = sc.nextInt();
		}
		System.out.print("原来的4个整数顺序为:");
		System.out.println(Arrays.toString(a));
		for (int i = 0; i < 4 / 2; i++) {
			int t = a[i];
			a[i] = a[3 - i];
			a[3 - i] = t;
		}
		System.out.println("现在的4个整数顺序为:" + Arrays.toString(a));
	}

	private static void j3x_4() {
		System.out.println("输入一个整数");
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		System.out.print(num + "由  ");

		for (int i = 2; i <= num; i++) {
			while (num % i == 0) {
				num /= i;
				System.out.print(i + " ");
			}
		}
		System.out.println("相乘得到");
	}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值