Question
Write a java program that plays the game Rock-Paper-Scissors. (Scissors cut paper; rock breaks scissors; paper covers rock.) The user will play against the computer.
Write a java program that plays the game Rock-Paper-Scissors. (Scissors cut paper; rock breaks scissors; paper covers rock.) The user will play against the computer. Scissors cut paper, rock breaks scissors, paper covers rock.
For the computers selection, the program will randomly generate a number 0, 1, or 2 representing rock, paper, or scissors. The program promts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws.
Sample run:
Rock (0), Paper (1), Scissors (2): 0 Enter The computer is scissors. You are rock. You win.
Rock (0), Paper (1), Scissors (2): 1 Enter The computer is paper. You are paper. It is a draw.
Analysis Input: You need to know which number the user wants. Use the secure random number generator to come up with a number for the computer.
Processing: Compare the users number and the computers number and see who wins. Translate the users and computers numeric choices into words.
Output: Display the computers choice. Display the users choice. Display the outcome.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started