//输入一个年份,判断是不是闰年(能被4整除但是不能被100整除,或是能被400整除) package doom1; import java.util.Scanner; public class thethreeweekwork1 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input =new Scanner(System.in); System.out.print("请输入一个年份:"); int i = input.nextInt(); if(i%4==0 && i%100!=0||i%400==0){ System.out.println(i+"年是闰年"); }else{ System.out.println(i+"年不是闰年"); } } }
//输入一个4位会员卡号,如果百位数字是3的倍数,就输出是幸运会员,否则就输出不是 package doom1; import java.util.Scanner; public class thethreeweekwork2 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.print("请输入会员编号:"); int i = input.nextInt(); if (i < 1000) { System.out.println(i + "不是会员编号"); } else if ((i % 1000 / 100) % 3 == 0) { System.out.println(i + "恭喜您是幸运会员"); } else { System.out.println(i + "很抱歉您不是幸运会员"); } } }
/* x+3 (x>0) 已知函数值,输入x,输入对应的y.y= 0 (x=0) x*2-1 (x<0) */ package doom1; import java.util.Scanner; public class thethreeweekwork3 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.print("请输入x的值:"); int i = input.nextInt(); if (i>0) { System.out.println("y的值为"+(i+3)); } else if (i == 0){ System.out.println("y的值为"+(0)); } else if(i<0){ System.out.println("y的值为"+(i*i-1)); } } }
//输入三个数,判断是否能构成三角形(任意两边之和大于第三边) package doom1; import java.util.Scanner; public class thethreeweekwork4 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.print("请输入第一个数:"); int a = input.nextInt(); System.out.println(); System.out.print("请输入第二个数:"); int b = input.nextInt(); System.out.println(); System.out.print("请输入第三个数:"); int c = input.nextInt(); if(a+b>c||a+c>b||b+c>a){ System.out.println(a+" "+b+" "+c+" "+"可以构成三角形"); }else{ System.out.println(a+" "+b+" "+c+" "+"不能构成三角形"); } } }