I Need To Add A Counter To Keep Track Of The Score Stopping At A Total Score Of

I need to add a counter to keep track of the score stopping at a total score of 5 for my rock paper scissor game and the text has caused me some headaches. Below is the source code.

import java.util.Scanner;public class RPS {  public static void main(String[] args) {      Scanner in = new Scanner(;      String playerOne; //Player A — “R”, “P”, or “S”      String playerTwo; //Player B      Scanner scan = new Scanner(;      System.out.println(” Player A enter R for Rock, P for Paper, S for Scissors: “);      playerOne =;      playerOne = playerOne.toLowerCase();      System.out.println(“Player B enter R for Rock, P for Paper, and S for Scissors”);      playerTwo =;      playerTwo = playerTwo.toLowerCase();      if (playerOne.equals(playerTwo)) {          System.out.println(“Tie”);      } else if (playerOne.equals(“r”)) {          if (playerTwo.equals(“s”)) {              System.out.println(“Rock beats scissors!”);          } else if (playerTwo.equals(“p”)) {              System.out.println(“Paper covers Rock!”);          } else if (playerOne.equals(“p”)) {              if (playerTwo.equals(“s”)) {                  System.out.println(“Scissors cut Paper!”);              } else if (playerTwo.equals(“r”)) {                  System.out.println(“Paper covers rock, you win!!”);              } else if (playerOne.equals(“s”)) {                  if (playerTwo.equals(“p”)) {                      System.out.println(“Scissors beat paper!”);                  }              } else if (playerTwo.equals(“r”)) {                  System.out.println(“Rock beats Scissors”);                                                }          }      }  }}

Leave a Reply

Your email address will not be published. Required fields are marked *