第三周作业
package diyici; import java.util.*; public abstract class diyici { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); int a=input.nextInt(); if(a%4==0&&a%100!=0||a%400==0) System.out.println("是闰年"); else{ System.out.println("不是闰年"); } }
package diyici; import java.util.*; public abstract class diyici { public static void main(String[] args) { System.out.println("请输入四位会员卡号"); Scanner s = new Scanner(System.in); int card = s.nextInt(); if (card >= 10000 || card < 1000) { System.out.println("输入的位数不正确"); return; } int bai = card / 100 % 10; if (bai % 3 == 0) { System.out.println("是幸运会员"); } else { System.out.println("不是幸运会员"); } } }
package diyici; import java.util.*; public abstract class diyici { 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(); int y=0; if(x>0){ y=x+3; }else if(x==0){ y=0; }else{ y=x*2-1; } System.out.println("y="+y); } }
package diyici; import java.util.*; public abstract class diyici { public static void main(String[] args) { Scanner AA = new Scanner(System.in); System.out.println("输入三个正整数"); int a = AA.nextInt(); int b = AA.nextInt(); int c = AA.nextInt(); if (a<=0||b<=0||c<=0){ System.out.println("输入错误,请重新输入"); }else if ((a+b)>c&&(a+c)>b&&(b+c)>a){ System.out.println("能构成三角形"); }else System.out.println("不能构成三角形"); } }
版权声明:本文为1234zz原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。