1.
package set; import java.util.Scanner; public class set { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("请输入年份:"); long year = input.nextLong(); if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) { System.out.println(year + "是闰年!"); } else { System.out.println(year + "不是闰年"); } } }
2.
package set; import java.util.Scanner; public class set { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); System.out.println("请输入会员号:"); int a=input.nextInt(); if((a%1000/100)%3==0){ System.out.println("恭喜您是幸运会员"); }else if(a<1000){ System.out.println("不是会员号"); }else{ System.out.println("抱歉您不是幸运会员"); } } }
3.
package set; import java.util.Scanner; public class set { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); System.out.println("请输入x值:"); int x=input.nextInt(); if(x>0){ System.out.println("y的值为"+(x+3)) ; }else if(x==0){ System.out.println("y的值为"+(0)); }else if(x<0){ System.out.println("y的值为"+(x*x-1)); } } }
4.
package set; import java.util.Scanner; public class set { 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(); System.out.println(); if (a + b > c || b + c > b || a + c > a) { System.out.println(a + "" + b + "" + c + "" + "可以构成三角形"); } else { System.out.println(a + "" + b + "" + c + "" + "不可以构成三角形"); } } }