Java Program Fix this Rock, Paper and scissor program so I can upload it to Hypergrade and it can pass all the test cases.  Here is the program, please fix thses program when I upload it to Hypergrade it does not pass the test cases and I can input any seeds as a command line. Also I do not need any thanks for playing or goodbye in the program: import java.util.Random; import java.util.Scanner;   public class RockPaperScissors {     public static void main(String[] args) {         if (args.length != 1) {             System.out.println("Please provide a seed as a command line argument.");             return;         }           long seed = Long.parseLong(args[0]);         Random random = new Random(seed);         Scanner scanner = new Scanner(System.in);           System.out.println("Enter 1 for rock, 2 for paper, and 3 for scissors.");           do {             int computerChoice = random.nextInt(3) + 1; // Fix computer choice range.             int userChoice = getUserChoice(scanner);               if (userChoice == -1) {                 continue;             }               System.out.println("Your choice: " + choiceToString(userChoice) + ". Computer choice: " + choiceToString(computerChoice) + ".");               int result = determineWinner(userChoice, computerChoice);             if (result == 0) {                 System.out.println("It's a draw.");             } else if (result == 1) {                 System.out.println("Computer wins.");             } else {                 System.out.println("You win.");             }               System.out.println("Would you like to play more? (yes/no)");         } while (scanner.next().equalsIgnoreCase("yes"));           System.out.println("Thanks for playing!");         scanner.close();     }       public static int getUserChoice(Scanner scanner) {         int choice;         while (true) {             System.out.print("Enter your choice: ");             if (scanner.hasNextInt()) {                 choice = scanner.nextInt();                 if (choice >= 1 && choice <= 3) {                     break;                 } else {                     System.out.println("Please respond 1, 2, or 3.");                 }             } else {                 scanner.next(); // Consume invalid input                 System.out.println("Please respond 1, 2, or 3.");             }         }         return choice; // Return the choice as is.     }       public static String choiceToString(int choice) {         switch (choice) {             case 1:                 return "rock";             case 2:                 return "paper";             case 3:                 return "scissors";             default:                 return "invalid";         }     }       public static int determineWinner(int userChoice, int computerChoice) {         if (userChoice == computerChoice) {             return 0; // Draw         } else if ((userChoice + 1) % 3 == computerChoice) {             return 1; // Computer wins         } else {             return 2; // User wins (changed from -1)         }     } }   Here is a part of the test casses:   Test Case 1       Command Line arguments:   123456789   Enter 1 for rock, 2 for paper, and 3 for scissors.\n 1ENTER Your choice: rock. Computer choice: paper.\n Computer wins.\n Would you like to play more?\n nENTER   Test Case 2       Command Line arguments:   123456789   Enter 1 for rock, 2 for paper, and 3 for scissors.\n 2ENTER Your choice: paper. Computer choice: paper.\n It's a draw.\n Would you like to play more?\n nENTER   Test Case 3       Command Line arguments:   123456789   Enter 1 for rock, 2 for paper, and 3 for scissors.\n 3ENTER Your choice: scissors. Computer choice: paper.\n You win.\n Would you like to play more?\n nENTER   Test Case 4       Command Line arguments:   123456789   Enter 1 for rock, 2 for paper, and 3 for scissors.\n 0ENTER Please respond 1, 2, or 3.\n Enter 1 for rock, 2 for paper, and 3 for scissors.\n 1ENTER Your choice: rock. Computer choice: paper.\n Computer wins.\n Would you like to play more?\n nENTER

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 Program

Fix this Rock, Paper and scissor program so I can upload it to Hypergrade and it can pass all the test cases. 

Here is the program, please fix thses program when I upload it to Hypergrade it does not pass the test cases and I can input any seeds as a command line. Also I do not need any thanks for playing or goodbye in the program:

import java.util.Random;
import java.util.Scanner;

 

public class RockPaperScissors {
    public static void main(String[] args) {
        if (args.length != 1) {
            System.out.println("Please provide a seed as a command line argument.");
            return;
        }

 

        long seed = Long.parseLong(args[0]);
        Random random = new Random(seed);
        Scanner scanner = new Scanner(System.in);

 

        System.out.println("Enter 1 for rock, 2 for paper, and 3 for scissors.");

 

        do {
            int computerChoice = random.nextInt(3) + 1; // Fix computer choice range.
            int userChoice = getUserChoice(scanner);

 

            if (userChoice == -1) {
                continue;
            }

 

            System.out.println("Your choice: " + choiceToString(userChoice) + ". Computer choice: " + choiceToString(computerChoice) + ".");

 

            int result = determineWinner(userChoice, computerChoice);
            if (result == 0) {
                System.out.println("It's a draw.");
            } else if (result == 1) {
                System.out.println("Computer wins.");
            } else {
                System.out.println("You win.");
            }

 

            System.out.println("Would you like to play more? (yes/no)");
        } while (scanner.next().equalsIgnoreCase("yes"));

 

        System.out.println("Thanks for playing!");
        scanner.close();
    }

 

    public static int getUserChoice(Scanner scanner) {
        int choice;
        while (true) {
            System.out.print("Enter your choice: ");
            if (scanner.hasNextInt()) {
                choice = scanner.nextInt();
                if (choice >= 1 && choice <= 3) {
                    break;
                } else {
                    System.out.println("Please respond 1, 2, or 3.");
                }
            } else {
                scanner.next(); // Consume invalid input
                System.out.println("Please respond 1, 2, or 3.");
            }
        }
        return choice; // Return the choice as is.
    }

 

    public static String choiceToString(int choice) {
        switch (choice) {
            case 1:
                return "rock";
            case 2:
                return "paper";
            case 3:
                return "scissors";
            default:
                return "invalid";
        }
    }

 

    public static int determineWinner(int userChoice, int computerChoice) {
        if (userChoice == computerChoice) {
            return 0; // Draw
        } else if ((userChoice + 1) % 3 == computerChoice) {
            return 1; // Computer wins
        } else {
            return 2; // User wins (changed from -1)
        }
    }
}
 
Here is a part of the test casses:
 

Test Case 1

 
 
 
Command Line arguments:
 
123456789
 
Enter 1 for rock, 2 for paper, and 3 for scissors.\n
1ENTER
Your choice: rock. Computer choice: paper.\n
Computer wins.\n
Would you like to play more?\n
nENTER
 

Test Case 2

 
 
 
Command Line arguments:
 
123456789
 
Enter 1 for rock, 2 for paper, and 3 for scissors.\n
2ENTER
Your choice: paper. Computer choice: paper.\n
It's a draw.\n
Would you like to play more?\n
nENTER
 

Test Case 3

 
 
 
Command Line arguments:
 
123456789
 
Enter 1 for rock, 2 for paper, and 3 for scissors.\n
3ENTER
Your choice: scissors. Computer choice: paper.\n
You win.\n
Would you like to play more?\n
nENTER
 

Test Case 4

 
 
 
Command Line arguments:
 
123456789
 
Enter 1 for rock, 2 for paper, and 3 for scissors.\n
0ENTER
Please respond 1, 2, or 3.\n
Enter 1 for rock, 2 for paper, and 3 for scissors.\n
1ENTER
Your choice: rock. Computer choice: paper.\n
Computer wins.\n
Would you like to play more?\n
nENTER

 

 
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Adjacency Matrix
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
  • SEE MORE 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