1. 程式人生 > >if else多重選擇結構

if else多重選擇結構

package myproject;
/**
 * 
 * @author 李瑞琦
 * if-else 雙選擇結構
 * if else if else 多重選擇結構
 *
 */
public class TestIfElse {
    public static void main(String[] args){
        /*int a = (int)(Math.random()*6+1);
        int b = (int)(Math.random()*6+1);
        int c = (int)(Math.random()*6+1);
        int total = a+b+c;
        if
(a==b&&b==c){ System.out.println("您的點數為豹子"); }else{ if(total>=10){ System.out.println("您扔出的點數為大"); }else{ System.out.println("您扔出的點數為小"); } }*/ int score = 75; if(score>=90){ System.out.println("帶你去北京玩"
); }else if(score>=80){ System.out.println("帶你去山東玩"); }else if(score>=70){ System.out.println("帶你去濟南玩"); }else if(score>=60){ System.out.println("帶你去泰安玩"); }else{ System.out.println("在家玩"); } } }