Java----Scissors (10 innings)

Source: Internet
Author: User

Package learning;
Import java.util.*;
public class guess{
public static void Main (String [] args) {
int j=0;
while (j<4) {
int count1=0;
int count2=0;
int count3=0;
for (int i=1;i<11;i++) {
System.out.println ("-------Scissors game-------");
System.out.println ("+i+", "Bureau");
SYSTEM.OUT.PRINTLN ("Please Punch: (1. Scissors 2. Stone 3. Cloth)");
Scanner in = new Scanner (system.in);
int person = In.nextint ();
int computer = (int) (Math.random () *3+1);
String marks = "fist";
String Marks2 = "fist";
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 are out of the" +marks+ ", the computer is" +MARKS2 ");
Count1 =count1+1;
}
else if (person==1&&computer==2| | person==2&&computer==3| | Person==3&&computer==1) {
System.out.println ("You Lose," + "You are out of the" +marks+ ", the computer is" +MARKS2 ");
Count2 =count2+1;
}
else {
System.out.println ("You win," + "You are out of the" +marks+ ", the computer is" +MARKS2 ");
Count3 =count3+1;
}
System.out.println ("You won the +count3+" bureau, "+" you lost the "+count2+" bureau, "+" Draw "+count1+" bureau ");
}
if (Count3>count2) {
System.out.println ("Congratulations, you won!" ");
Break
}
if (Count3<count2) {
System.out.println ("I'm sorry, you lost!") ");
Break
}
if (Count3==count2) {
System.out.println ("Qifengduishou, Draw! Let's do it again! ");
j + +;
Continue
}
}
}
}

Java----Scissors (10 innings)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.