Import java.util.*;
public class Guess {
public static void Main (string[] args) {
Scanner in=new Scanner (system.in);
int a=0;
int b=0;
int c=0;
The int i=0;//declares three variables a B c, which is used to receive the number of wins and loss, declares the variable i user loop, loops inside the declaration, and cannot be used outside the loop.
System.out.println ("**************** stone, scissors, cloth game ****************");
for (i=1;i<=5;i++) {
System.out.println ();
System.out.println ("+i+" Times: "+" Please punch (1. Scissors 2. Stone 3. Cloth) ");
int person =in.nextint ();
int computer= (int) (Math.random ()) +1;
String marks= "fist";//Make a mark here.
String marks2= "Diannao";//Make a mark for the computer here.
Switch (person) {
Case 1:
Marks= "Scissors";
Break
Case 2:
Marks= "Stone";
Break
Case 3:
marks= "cloth";
Break
}
Switch (computer) {
Case 1:
Marks2= "Scissors";
Break
Case 2:
Marks2= "Stone";
Break
Case 3:
marks2= "cloth";
Break
}
if (person==computer) {
SYSTEM.OUT.PRINTLN ("Draw!") + "You Out is:" +marks+ "" + "computer Out is:" +MARKS2);
A+=1;
}else if (person==1&&computer==2| | person==2&&computer==3| | Person==3&&computer==1) {
System.out.println ("-_-you lost!" "+" You Out of is: "+marks+" "+" computer Out is: "+MARKS2);
B+=1;
}else{
System.out.println ("You won!" "+" You Out of is: "+marks+" "+" computer Out is: "+MARKS2);
C+=1;
}
}
System.out.println ();
System.out.println ("******************** Game Results ********************");
SYSTEM.OUT.PRINTLN ("You have played a total of" + "+ (i-1) +" + "Bureau! ");
System.out.println ("Win" + "+c+" "+" innings!) "+" "+" flat out "+" "+a+" "+" Bureau! "+" "+" Lost "+" "+b+" "+" Bureau! ");
if (c>b) {
System.out.println ();
System.out.println ("Congratulations, composite result: you won!") ");
}
else if (c==b) {
System.out.println ();
System.out.println ("Congratulations, composite result: Draw! ");
}
else {
System.out.println ();
System.out.println ("Unfortunately, the result: you lost!") ");
}
System.out.println ("******************************************************");
}
}
This article is from the "11400174" blog, please be sure to keep this source http://11410174.blog.51cto.com/11400174/1759489
Simple: Stone scissors cloth game Source