{
System.out.println("Please enter R(ock), S(cissor) or P(aper)");
Scanner scan = new Scanner(System.in);
Random generator = new Random();
String personPlay;
String personPlayUpper;
String computerPlay = "N";
int computerInt = generator.nextInt(3); //Randomly generate number used to determine computer's play
personPlay = scan.nextLine(); //Get player's play -- note that this is stored as a string
personPlayUpper = personPlay.toUpperCase(); //Make player's play uppercase for ease of comparison
The two System.out.println commands just above the If statement execute properly, but for some reason, the If statements themselves will not.
Any help is greatly appreciated! Thanks![/code]
Sponsor Sponsor
Insectoid
Posted: Fri Sep 21, 2012 7:12 am Post subject: RE:If statement will not execute.
You're comparing strings. '=' will not work. Use String.equals() instead.
Srlancelot39
Posted: Fri Sep 21, 2012 8:06 am Post subject: RE:If statement will not execute.