GameAA.java This program allows a user to play “Rock, paper, scissors” against the computer.  Use a random number generator to generate the computer’s selection.  Your code should ask the user what they choose and then report the computer’s choice and who wins. This code should run in a loop and should end when the user chooses to end.  (Make sure your random number generator chooses a new number each time the loop runs.)  ALSO, your code should keep track of the number of times you win, the number of times you lose, and the number of ties.  When the user exits, these statistics should be displayed.  (Consider using a different counter variable to keep track of each value.) Make sure your code accounts for inputs that are out of the acceptable range.  For example, if you ask the user to type 0 to end, 1 for Rock, 2 for Paper, and 3 for Scissors, your code should tell the user that they entered an invalid choice if they select 4.  (You do not have to account for users who crash the program by entering Strings when an integer is expected.) There’s some example output below.  Your output messages should be an exact match to the sample output (except for results that differ due to randomness).  In particular, do not change the text, ordering of choice, or anything else in the introductory message to the user. Output Example (User input is marked with >>>. Everything else is what you print to the screen.) Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>3   You chose scissors.  The computer chose rock.  You lose! Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>1   You chose rock.  The computer chose scissors.  You win! Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>1   You chose rock.  The computer chose rock.  It’s a tie! Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>2   You chose paper.  The computer chose paper.  It’s a tie! Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>4   Invalid selection. Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End) >>>0   You won 1 time. The computer won 1 time. You tied with the computer 2 times. Thanks for playing! Goodbye!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

GameAA.java

This program allows a user to play “Rock, paper, scissors” against the computer.  Use a random number generator to generate the computer’s selection.  Your code should ask the user what they choose and then report the computer’s choice and who wins.

This code should run in a loop and should end when the user chooses to end.  (Make sure your random number generator chooses a new number each time the loop runs.) 

ALSO, your code should keep track of the number of times you win, the number of times you lose, and the number of ties.  When the user exits, these statistics should be displayed.  (Consider using a different counter variable to keep track of each value.)

Make sure your code accounts for inputs that are out of the acceptable range.  For example, if you ask the user to type 0 to end, 1 for Rock, 2 for Paper, and 3 for Scissors, your code should tell the user that they entered an invalid choice if they select 4.  (You do not have to account for users who crash the program by entering Strings when an integer is expected.)

There’s some example output below.  Your output messages should be an exact match to the sample output (except for results that differ due to randomness).  In particular, do not change the text, ordering of choice, or anything else in the introductory message to the user.

Output Example (User input is marked with >>>. Everything else is what you print to the screen.)

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>3

 

You chose scissors.  The computer chose rock.  You lose!

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>1

 

You chose rock.  The computer chose scissors.  You win!

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>1

 

You chose rock.  The computer chose rock.  It’s a tie!

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>2

 

You chose paper.  The computer chose paper.  It’s a tie!

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>4

 

Invalid selection.

Let’s play Rock, Paper, Scissors! Make your selection: (1 for Rock, 2 for Paper, 3 for Scissors, 0 to End)

>>>0

 

You won 1 time.

The computer won 1 time.

You tied with the computer 2 times.

Thanks for playing! Goodbye!

in java

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education