if 多选择结构
-
有单、双if可知,在生活中我们很多时候的选择也不仅仅只有两个,所有我们需要一个多选择结构来处理这类情况
-
语法
-
-
package com.buli.struct; import java.util.Scanner; /** * Created by JKK on 2021/6/22. */ public class IfDemo03 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入成绩 :"); int score= scanner.nextInt(); if (score==100){ System.out.println("满分 !!"); }else if (score<100&&score>=90){ System.out.println("优秀!!"); }else if (score<90&&score>=60){ System.out.println("良好!!"); }else if (score<60){ System.out.println("抱歉 ,不及格"); } scanner.close(); } }