/** * ClassName: Test01 * * @Author 爱扣钉-陈晨 * @Create 2023/10/28 9:27 * @Version 1.0 */ public class Test10 { /* if语句 2023.8.24是小日本子核废水排污的日子,这一天终将被历史铭记. 需求:定义时间20230824 如果等于此刻 投放核弹 炸死小日本. String int 小日本最终的结局只有两个,被核弹消灭,被海洋淹没.但是需要形成一定的条件. 如果有战争小日本被核弹消灭,没有被海洋淹没. 需求:定义定义变量 war 如果是true 用核弹消灭小日本,否则被海水淹没. 小明公司出品干死小日本游戏,在游戏中对于杀死小日本人数,给出响应奖励. - 杀死 10人以内, 奖励人民币100元. - 杀死 10 - 100 人以内, 奖励华为手机一部. - 杀死 100 - 1000 人以内, 奖励奇瑞汽车一台. - 杀死 1000 - 10000 人以内, 奖励保时捷. */ public static void main(String[] args) { int date = 20230825; if (date == 20230824){ System.out.println("投放核弹 炸死小日本"); } //if else boolean war = false; if (war){ System.out.println("用核弹消灭小日本"); }else{ System.out.println("被海水淹没"); } //if else if ... else System.out.println("-----------------"); int persons = -1; if ( persons > 0 && persons <=10 ){ System.out.println("奖励人民币100元."); }else if (persons > 10 && persons <=100){ System.out.println("奖励华为手机一部."); }else if (persons > 100 && persons <=1000){ System.out.println("汽车."); }else if (persons > 1000 && persons <=10000){ System.out.println("奖励保时捷."); }else{ System.out.println("没有对应的奖励"); } } }