Answer:
Step-by-step explanation:
int rounds = 0;
int wins = 0;
int losses = 0;
int draws = 0;
while (true) {
// Get the user's selection
System.out.println("Let's play RPSLR!");
System.out.println("1. Rock");
System.out.println("2. Paper");
System.out.println("3. Scissors");
System.out.println("4. Lizard");
System.out.println("5. Spock");
System.out.print("What is your selection? ");
int userSelection = keyboard.nextInt();
// Get the computer's selection
int computerSelection = random.nextInt(5) + 1;
// Compare the user's selection to the computer's selection
if (userSelection == 1 && computerSelection == 3 ||
userSelection == 1 && computerSelection == 4 ||
userSelection == 2 && computerSelection == 1 ||
userSelection == 2 && computerSelection == 5 ||
userSelection == 3 && computerSelection == 2 ||
userSelection == 3 && computerSelection == 4 ||
userSelection == 4 && computerSelection == 2 ||
userSelection == 4 && computerSelection == 5 ||
userSelection == 5 && computerSelection == 1 ||
userSelection == 5 && computerSelection == 3) {
// User wins
System.out.println("The User has won.");
wins++;
} else if (userSelection == computerSelection) {
// Draw
System.out.println("It's a draw.");
draws++;
} else {
// Computer wins
System.out.println("The Computer has won.");
losses++;
}
// Ask if the player wants