if-else if-else;多选择结构

package class2; /**

  • if-else if-else;多选择结构

  • @author 86198 * */ public class test3 { public static void main(String[] args){ int age = (int)(100*Math.random()); System.out.println("年龄是:"+age+",属于"); if(age<15){ System.out.println("儿童,喜欢玩"); }else if(age<25){ System.out.println("青年,喜欢学习"); }else if(age<45){ System.out.println("中年,喜欢钓鱼"); }else if(age<65){ System.out.println("老年,喜欢养生"); }else if(age<85){ System.out.println("寿星,喜欢下象棋"); }else{ System.out.println("老寿星,注意身体"); } }

}

posted @ 2020-03-23 19:29  上帝是个程序员  阅读(278)  评论(0编辑  收藏  举报