Note that there are some explanatory texts on larger screens.

plurals
  1. POIf statement not equal to
    text
    copied!<pre><code>import java.util.Scanner; public class RockPaperScissors { public static void main (String[] args) { Scanner scan = new Scanner (System.in); System.out.println("Player 1: Choose rock, paper or scissors: "); String Player1 = scan.next().toLowerCase(); System.out.println("Player 2: Choose rock, paper or scissors: "); String Player2 = scan.next().toLowerCase(); System.out.println ("Player 1 chose " + Player1); System.out.println ("Player 2 chose " + Player2); if (Player1.!equals("rock" + "paper" + "scissors") { System.out.println ("Please insert either Rock Paper or Scissors!); } if (Player1.equals(Player2)) { System.out.println ("Its a tie!"); } if ((Player1.equals("rock")) &amp;&amp; (Player2.equals("paper"))) { System.out.println ("Player 2 wins!"); } else if ((Player1.equals("paper")) &amp;&amp; (Player2.equals("rock"))) { System.out.println ("Player 1 wins!"); } if ((Player1.equals("scissors")) &amp;&amp; (Player2.equals("paper"))) { System.out.println ("Player 1 wins!"); } else if ((Player1.equals("paper")) &amp;&amp; (Player2.equals("scissors"))) { System.out.println ("Player 2 wins!"); } if ((Player1.equals("rock")) &amp;&amp; (Player2.equals("scissors"))) { System.out.println ("Player 1 wins!"); } else if ((Player1.equals("scissors")) &amp;&amp; (Player2.equals("rock"))) { System.out.println ("Player 2 wins!"); } } </code></pre> <p>}</p> <p>I have made a simple Rock Scissors Paper game, however I want to implement validation so the user will be notified if they enter anything other than Rock Paper Scissors. I had a go with <code>.!equals</code> however I'm getting an error saying <code>&lt;identifier&gt;</code> expected.</p> <p>Thanks! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload