1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
package 控制语句;
public class TestIf { public static void main(String[] args) { double x = 6*Math.random(); int age = (int)(80*Math.random()); System.out.println(x); System.out.println(age); if(x <= 2) { System.out.println("Small"); } if(x >= 2) { System.out.println("Large"); } if(x <= 2) { System.out.println("Small"); }else { System.out.println("Large"); } if(age <= 15) { System.out.println("儿童"); }else if(age <= 25) { System.out.println("青年"); }else if(age <= 45) { System.out.println("中年"); }else if(age <= 80) { System.out.println("老年"); } } }
|