Write a Java program that can play the game Rock, Paper, Scissors with String variables.
- String variables
Make the following modifications to your Rock-Paper-Scissors game:
- Use Strings instead of numbers for the guesses.
- The user should input a string.
- The computer will still guess with a number, but convert the random number to a String.
- Compare the Strings when checking for the winner.
- Your program should ignore the letter case.
- If the user enters an invalid response, ask the user to enter a valid response. The program can then quit.
Again, test all combinations to make sure your game works properly. Test with both upper and lower case responses from the user. Also, test with invalid inputs.
- Duplicate your original Rock-Paper-Scissors game file before you begin. Don’t just modify your original program so that you have a functional program just in case Mr. Didier needs to see the game again for grading..
- You cannot use the normal Boolean phrase “(String1 == String2)”. It does not work on Strings in Java. You must use the “String1.equals (String2)” phrase.
- You can use either the String.toLowerCase or String.equalsIgnoreCase to ignore case.
AP College Board 2.6: String Objects
AP College Board 2.7: String Method
Bill Barnum’s AP Computer Science A test prep videos