// 目标:学会使用if分支结构解决问题,理解其流程public class ifDemo1 { public static void main(String[] args) { // 需求:心跳(60 - 100)之间是正常的,否则系统提示进一步检查 // 格式1:if(条件表达式){代码。。。。} int heartBeat = 30; if (heartBeat <60 || heartBeat>100){ // if()括号里面的表达式为true,输出大括号里面的内容 System.out.println("你的心跳是:" + heartBeat + "心跳异常,需要进行进一步检查"); } System.out.println("检查结束");// 格式二:if... else // 需求发红包 double money = 1; if (money>=1314){ System.out.println("红包发送成功"); } else { System.out.println("红包发送失败,你个穷狗"); } //格式3:if(条件表达式){代码。。。}else if(条件表达式){代码。。。}。。。。else{代码。。。} // 绩效系统:0-60C 60-80B 80-90A 90-100A+ int score = 199; if (score >= 0 && score <60){ System.out.println("c"); } else if (score>=60 && score<80){ System.out.println("B"); } else if (score>=80 && score < 90){ System.out.println("A"); } else if (score >=90 && score<=100){ System.out.println("A++"); } else { System.out.println("你的分数有毛病"); } }}