1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package 控制语句;
public class TestSwitch { public static void main(String[] args) { int a = (int)(6*Math.random())+1; System.out.println("骰点:"+a); switch(a) { case 1: System.out.println("1点"); break; case 2: System.out.println("2点"); break; case 3: System.out.println("3点"); break; case 4: System.out.println("4点"); break; case 5: System.out.println("5点"); break; case 6: System.out.println("6点"); break; default: break; } } }
|