Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 10 Weeks Ago, 5 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need help to add new code that causes the game to stop when 1 user has 5 more wins than the other user. The program should keep a running score of each user after each round.
I also need help entering R, P or S (String input) as a option
Â
/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/package GameProgram;/**** @author Samuel*/import java.util.Random;import java.util.Scanner;public class GameProgram {public static void main(String[] args){/* Random number generator */Random random = new Random();/** Integer variables to hold the user and computer choice.** 0 = Rock* 1 = Paper* 2 = Scissors**/try ( /* Scanner object for input */ Scanner scanner = newScanner(System.in)) {int user1Choice, user2Choice;// Showing prompt and user inputSystem.out.println("Player One enter move (0 = Rock; 1 = Paper;2 = Scissors):");user1Choice = scanner.nextInt();// Checking if user1Choice is 0, 1, or 2.// Showing prompt and user inputSystem.out.println("Player Two enter move (0 = Rock; 1 = Paper;2 = Scissors):");user2Choice = scanner.nextInt();// Checking if user2Choice is 0, 1, or 2.if(user1Choice < 0 || user1Choice > 2){System.out.println("Invalid choice. Ending program.");// Exit programSystem.exit(0);}if(user2Choice < 0 || user2Choice > 2){System.out.println("Invalid choice. Ending program.");// Exit programSystem.exit(0);}// Determining the winner// If the choices are equal, it's a tie.if(user1Choice == user2Choice){if(user1Choice == 0 && user2Choice == 0){
Â
-----------