标签:表示 person oid case mat compute string static print
Scanner和if,switch的应用
import java.util.*;//*表示通用符
public class pakcage{
public static void main{
System.out.println("欢迎来到猜拳游戏”);
System.out.println("请出拳:(1,石头;2,剪刀;3,布;)");
Scanner xx=new Scanner(System.in);
System.out.println("请出拳");
int person=xx.nextInt();
int computer=(int)(Math.randon()*3)+1;
String marks="石头";
Switch(person){
case 1:
marks =“石头”;
break;
case 2:
marks =“剪刀”;
break;
case 3:
marks =“布”;
break;
}String marks1=“石头”;
switch(computer){
case 1:
marks1 =“石头”;
break;
case 2:
marks1 =“剪刀”;
break;
case 3:
marks1 =“布”;
break;
}
if(person==computer){
System.out.println("你出的是:"+marks+“,电脑出的是:”+marks1+“,0.0”+“,打成平手”);
}else if(person==1&&computer==3||person==2&&computer==1||person==3&&computer==2){
System.out.println("你出的是:"+marks+“,电脑出的是:”+marks1+“,-_-”+“,你输了”) ;
} else{
System.out.println("你出的是:"+marks+“,电脑出的是:”+marks1+“,^_^”+",你赢了”);
}
}
}
标签:表示 person oid case mat compute string static print
原文地址:http://www.cnblogs.com/Ariesmu/p/6964277.html