importjava.util.Scanner;publicclassBMI{publicstaticvoidmain(String[] args){System.out.println("请输入您以英镑为单位的身高,谢谢配合。");System.out.println("请输入您以英尺为单位的体重,谢谢!");Scanner height1 =newScanner(System.in);double height = height1.nextDouble();Scanner weight1 =newScanner(System.in);double weight = weight1.nextDouble();double a = height *0.0254;double b = weight *0.45359237;System.out.println("height"+ a);System.out.println("weight"+ b);double bmi = b / a / a;System.out.println("bmi="+ bmi);if(bmi<18.5){System.out.println("偏廋");}elseif(18.5<=bmi && bmi<25.0){System.out.println("正常");}elseif(25<=bmi && bmi<30.0){System.out.println("偏胖");}else{System.out.println("肥胖");}}}
第二题
importjava.util.Scanner;publicclassYear{publicstaticvoidmain(String[] args){System.out.println("请输入需要判断的年份");Scanner year1 =newScanner(System.in);int year = year1.nextInt();if(year %4==0&& year %100!=0|| year %400==0){System.out.println("该年为润年");}else{System.out.println("该年为平年");}}}
第三题
importjava.util.Random;importjava.util.Scanner;publicclass lotteryticket {publicstaticvoidmain(String[] ages){System.out.println("请说出来你的答案。");Scanner number1 =newScanner(System.in);int number = number1.nextInt();int a1 = number /10;int b1 = number %10;Random randow =newRandom();int answer = randow.nextInt(99)+10;System.out.println("answer"+ answer);int a = answer /10;int b = answer %10;System.out.println("a="+ a);System.out.println("b="+ b);if(number == answer){System.out.println("恭喜您获得10000美金!!!");}elseif(a1 == b && b1 ==a ){System.out.println("恭喜您获得3000美金!!!");}elseif(a1 == a || a1 ==b || b1==a || b1 ==b){System.out.println("恭喜您获得3000美金!!!");}else{System.out.println("谢谢惠顾!!!");}}}
第四题
importjava.util.Scanner;publicclass palindrome {publicstaticvoidmain(String[] args){System.out.println("请输入一个三位数。");Scanner number1 =newScanner(System.in);int number = number1.nextInt();int a = number /100;int b = number/10%10;int c = number%10;System.out.println("a="+ a);System.out.println("b="+ b);System.out.println("c="+ c);if(a==c){System.out.println("该是个回文数"+ number);}else{System.out.println("该数不是回文数");}}}