Question: 2. Using the random number generator complete the code for Rock-Paper-Scissor game. (Hint conditional statements such as While loop or if-else statements can be used).

 2. Using the random number generator complete the code for Rock-Paper-Scissor

2. Using the random number generator complete the code for Rock-Paper-Scissor game. (Hint conditional statements such as While loop or if-else statements can be used). A. A user can choose 1, 2, and 3 for Rock, Paper, and Scissor respectively then compare with a random integer number which is the computer's choice. Finally display the result of game. B. Make sure to show all the instructions using print commands so a user knows what to do. import java.util."; // To be able to use Scanner public class Q1_RP { public static void main(String args[]) { Scanner in Choice = new Scanner(System.in); // Allowing user to pick a choice System.out.println("Please input choice: 1 for Rock 2 for Paper 3 for Scissors "); Random R = new Random(); // Using Random class from Slides Chapter 5 day 2 int Comp = R.nextInt(3) + 1; // Using R to generate choices from 0 - 2 then adding 1 for // computer int User = inChoice.nextInt(); // Eventually picking user's input here and starting // nine possible scenarios

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!