Simple: Stone scissors cloth game Source

Source: Internet
Author: User

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

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.