第三周作业
import java.util.*; public class lqh { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("判断是否为闰年:"); Scanner input=new Scanner(System.in); int a = input.nextInt(); if(a%4==0&&a%4!=0) { System.out.println("是润年"); }else if(a%400==0) { System.out.println("是润年"); }else { System.out.println("不是闰年"); } } }
import java.util.*; public class lqh { public static void main(String[] args) { System.out.println("请输入一个会员卡号:"); Scanner sc = new Scanner(System.in); int a = sc.nextInt(); if((a /100%10) %3 ==0){ System.out.println("是幸运会员"); }else{ System.out.println("不是幸运会员"); } } }
import java.util.*; public class lqh { public static void main(String[] args) { Scanner SC=new Scanner(System.in); System.out.println("请输入x"); double x=SC.nextDouble(); double y; if(x > 0){ y = (x + 3); }else if(x == 0){ y = 0; }else{ y = x*2-1; } System.out.println("输出y的值" +y); } }
import java.util.*; public class lqh { public static void main(String[] args) { Scanner SC=new Scanner(System.in); System.out.println("请输入三个数"); double x=SC.nextDouble(); double y=SC.nextDouble(); double z=SC.nextDouble(); if((x+y)>z && (x+z)>y && (y+z)>x){ System.out.println("可以构成三角形"); }else{ System.out.println("不能构成三角形"); } } }