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!
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

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









