1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import java.util.*;
- class TestSwitch06Ex
- {
- public static void main(String[] args)
- {
-
-
- int a = (int)(Math.random() *5) + 1;
- int b = (int)(Math.random() *5) + 1;
- int c = (int)(Math.random() *5) + 1;
-
- boolean flag = false;
- Scanner sc = new Scanner(System.in);
-
- System.out.println("输入“豹子”, “大”,“小”");
-
- String str = sc.next();
-
-
- switch(str){
- case "豹子":
- if (a && b && b == c ){
- flag = true;
- }
- break;
- case "大":
- if ((a + b + c) > 9 ){
- flag = true;
- }
- break;
- case "小":
- if ((a + b + c) < 9 ){
- flag = true;
- }
- break;
- }
- if (flag){
- System.out.println("abc="+a+"-"+b+"-"+c+":猜对了");
- }else{
- System.out.println("abc="+a+"-"+b+"-"+c+":猜错了");
- }
- }
- }
|