Java Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is often used to pass time (or sometimes to make decisions.) The rules of the game are outlined below: • Scissors cuts Paper • Paper covers Rock • Rock crushes Lizard • Lizard poisons Spock • Spock smashes Scissors • Scissors decapitates Lizard • Lizard eats Paper • Paper disproves Spock • Spock vaporizes Rock • Rock crushes Scissors Write a program that simulates the game of Rock Paper Scissors Lizard Spock! • The user should be able to enter Strings for each of their choices (e.g. “Rock” for Rock, “Paper” for Paper etc…). o The code should also ensure that the user only enters the strings Rock, Paper or Scissors (and they should be able to enter upper or lower case versions). § Use a while loop with the equalsIgnoreCase method from the String class for best results! • The computer should generate a random value 0, 1, 2, 3, or 4 that would be translated into Rock, Paper, Scissors, Lizard or Spock respectively. o Use a switch statement to store the computer’s result as a String. (e.g. if the case matches 0, then the computer’s choice should be stored as “Rock” in a String variable.) • The program then determines according to the rules above who wins the game. o Use nested if else statements to determine the winner o You may also use the logical && operator to combine conditions! • Extra credit (10 points): Use a do while loop to Modify your program so that it asks the user if they want to replay the game. The program should replay the game as long as the user enters “yes”, and quits if the user enters “no”. If the user enters a value other than yes or no, the program should ask the user to reenter one of those values (using another while loop for input validation). • Extra credit (5 points) If the game is allowed to be replayed, keep track of the number of games played, the number of ties, the number of times the user wins and the number of times the computer wins in the game. At the end of the game (when the user presses no), the program should generate a report showing this data. Tip: • This code requires careful planning. Analyze all the possible ways the player and computer can computer can and create an outline (or algorithm or pseudocode) to help you keep track of all of the options! o An algorithm is a step by step set of instructions designed to help you solve the problem. o Psuedocode is “fake code”. It is a mixture of text and java syntax that documents the steps in your proposed solution. Here is a sample of the solution (with extra credit parts included): Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Towel Illegal choice: Towel Re-enter your play: Rock Computer chooses Rock It's a tie! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Paper Computer chooses Paper It's a tie! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Scissors Computer chooses Rock Rock crushes Scissors. Computer wins!! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Lizard Computer chooses Lizard It's a tie! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Spock Computer chooses Spock It's a tie! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Paper Computer chooses Lizard Lizard eats paper. Computer wins!! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Lizard Computer chooses Paper Lizard eats Paper. You win!! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Spock Computer chooses Paper Paper disproves Spock. Computer wins!! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Rock Computer chooses Paper Paper covers Rock. Computer wins!! Play again? Enter yes or no: yes Let's play Rock, Paper, Scissors, Lizard, Spock! Enter your choice: Scissors Computer chooses Scissors It's a tie! Play again? Enter yes or no: whatever Sorry, that response is invalid. Enter yes or no: no Number of games played: 10 You won: 1 times! Computer won: 4 times! There were: 5 tie games! Thanks for playing!

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

Java
Rock Paper Scissors Lizard Spock
Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is
often used to pass time (or sometimes to make decisions.) The rules of the game are outlined
below:
• Scissors cuts Paper
• Paper covers Rock
• Rock crushes Lizard
• Lizard poisons Spock
• Spock smashes Scissors
• Scissors decapitates Lizard
• Lizard eats Paper
• Paper disproves Spock
• Spock vaporizes Rock
• Rock crushes Scissors
Write a program that simulates the game of Rock Paper Scissors Lizard Spock!
• The user should be able to enter Strings for each of their choices (e.g. “Rock” for Rock,
“Paper” for Paper etc…).
o The code should also ensure that the user only enters the strings Rock, Paper or
Scissors (and they should be able to enter upper or lower case versions).
§ Use a while loop with the equalsIgnoreCase method from the String class
for best results!
• The computer should generate a random value 0, 1, 2, 3, or 4 that would be translated
into Rock, Paper, Scissors, Lizard or Spock respectively.
o Use a switch statement to store the computer’s result as a String. (e.g. if the case
matches 0, then the computer’s choice should be stored as “Rock” in a String
variable.)
• The program then determines according to the rules above who wins the game.
o Use nested if else statements to determine the winner
o You may also use the logical && operator to combine conditions!
• Extra credit (10 points): Use a do while loop to Modify your program so that it asks the
user if they want to replay the game. The program should replay the game as long as the
user enters “yes”, and quits if the user enters “no”. If the user enters a value other than
yes or no, the program should ask the user to reenter one of those values (using another
while loop for input validation).
• Extra credit (5 points) If the game is allowed to be replayed, keep track of the number
of games played, the number of ties, the number of times the user wins and the number
of times the computer wins in the game. At the end of the game (when the user presses
no), the program should generate a report showing this data.
Tip:
• This code requires careful planning. Analyze all the possible ways the player and
computer can computer can and create an outline (or algorithm or pseudocode) to help
you keep track of all of the options!
o An algorithm is a step by step set of instructions designed to help you solve the
problem.
o Psuedocode is “fake code”. It is a mixture of text and java syntax that documents
the steps in your proposed solution.
Here is a sample of the solution (with extra credit parts included):
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Towel
Illegal choice: Towel
Re-enter your play: Rock
Computer chooses Rock
It's a tie!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Paper
Computer chooses Paper
It's a tie!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Scissors
Computer chooses Rock
Rock crushes Scissors. Computer wins!!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Lizard
Computer chooses Lizard
It's a tie!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Spock
Computer chooses Spock
It's a tie!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Paper
Computer chooses Lizard
Lizard eats paper. Computer wins!!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Lizard
Computer chooses Paper
Lizard eats Paper. You win!!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Spock
Computer chooses Paper
Paper disproves Spock. Computer wins!!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Rock
Computer chooses Paper
Paper covers Rock. Computer wins!!
Play again? Enter yes or no: yes
Let's play Rock, Paper, Scissors, Lizard, Spock!
Enter your choice: Scissors
Computer chooses Scissors
It's a tie!
Play again? Enter yes or no: whatever
Sorry, that response is invalid.
Enter yes or no: no
Number of games played: 10
You won: 1 times!
Computer won: 4 times!
There were: 5 tie games!
Thanks for playing!

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
Random Class and its operations
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
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