The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 5 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
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(System.in);
     String playerOne; //Player A -- "R", "P", or "S"
     String playerTwo; //Player B
     Scanner scan = new Scanner(System.in);
     System.out.println(" Player A enter R for Rock, P for Paper, S for Scissors: ");
     playerOne = scan.next();
     playerOne = playerOne.toLowerCase();
     System.out.println("Player B enter R for Rock, P for Paper, and S for Scissors");
     playerTwo = scan.next();
     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");
                 Â
                             }
         }
     }
 }
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly