Answer: Here is some sample code that demonstrates how to complete the assignment using Java:
import java.util.Random;
import java.util.Scanner;
public class RPSLR {
public static void main(String[] args) {
// Initialize scanner for reading user input
Scanner scanner = new Scanner(System.in);
// Initialize random number generator for computer's selection
Random random = new Random();
// Initialize counters for rounds, wins, losses, and draws
int rounds = 0;
int wins = 0;
int losses = 0;
int draws = 0;
// Main game loop
while (true) {
// Get 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 = scanner.nextInt();
// Get computer's selection
int computerSelection = random.nextInt(5) + 1;
// Compare selections and determine outcome
String outcome;
if (userSelection == computerSelection) {
outcome = "draw";
draws++;
} else 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)) {
outcome = "win";
wins++;
} else {
outcome = "lose";
losses++;
}
// Print outcome of round
String userSelectionString;
String computerSelectionString;
if (userSelection == 1) {
userSelectionString = "Rock";
} else if (userSelection == 2) {
userSelectionString = "Paper";
} else if (userSelection == 3) {
userSelectionString = "Scissors";
} else if (userSelection == 4) {
userSelectionString = "Lizard";
} else {
userSelectionString = "Spock";
}
if (computerSelection == 1) {
computerSelectionString = "Rock";
} else if (computerSelection == 2) {
computerSelectionString = "Paper";
} else if (computerSelection == 3) {
computerSelectionString = "Scissors";
} else if (computerSelection == 4) {
computerSelectionString = "Lizard";
} else {
computerSelectionString = "Spock";
}