Java if-else if-else多选择结构代码
package cn.geekeryi; public class IfTest03 { public static void main(String[] args) { int age = (int) (100 * Math.random()); System.out.println("年龄:" + age + " 属于"); if (age < 18) { System.out.println("未成年人"); } else if (age < 30) { System.out.println("青年"); } else if (age < 50) { System.out.println("中年"); } else { System.out.println("老年"); } } }