The program of playing scissors with the computer in the loop mode (setting the winning condition--losing 3 times or winning 3 times is the exit)
Package eduask01;
Import java.util.*;
public class Rask03 {
public static void Main (String[]args) {
Scanner sc=new Scanner (system.in);
int m=0,n=0;//The number of wins or losses accumulated
for (;;) {//Dead loop for game
System.out.println ("Scissors game: 1." means stone 2. Means scissors 3. Indicate cloth. Please enter a number scissors ");
int Num=sc.nextint ();//I guess the fist
int num= (int) (Math.random () *3+1);//Computer random punch
Switch (num) {///own 3 cases and explain separately
Case 1:
System.out.println ("You Are out of stone:");
Case 2:
System.out.println ("You Are out of scissors:");
Case 3:
System.out.println ("You are out of cloth:");
}switch (Num) {//Computer 3 in case
Case 1:
SYSTEM.OUT.PRINTLN ("The computer is a stone:");
Case 2:
SYSTEM.OUT.PRINTLN ("Computer Out of Scissors:");
Case 3:
SYSTEM.OUT.PRINTLN ("Computer Out of a cloth:");
}
if (num==num) {//Decision Draw
System.out.println ("-_-draw");
}else if (num==1&&num==2| | num==2&&num==3| | Num==3&&num==1) {//Decision WINS
System.out.println ("^-^ Congratulations on your victory"); M+=1;
}else {System.out.println ("O-o is sorry you Lost"); n+=1;} The other is the case of loss.
if (m==3) {System.out.println ("You have won 3 innings have exited the scissors game"); Won 3 times.
else if (n==3) {System.out.println ("The computer has won 3 times you have exited the Scissors game"); Lost 3 times.
}
}
}
Scissors Game Java Basics