+ 1

Rock, paper, error

I'm making a game for class but there's an error. Whenever I put in something like "paper rock" it will give me the answer I want: " Rock wins! :D" along with a bunch of other answered I didn't want. Sample input: scissors rock Sample output: "Scissors Wins!" "Rock Wins!" "Paper Wins!" etc. What can I do to make it stop doing that and only print out the RIGHT answer? public class RockPaperScissors { public static void main(String[] args) throws Exception { String personPlay; //User's play -- "R", "P", or "S" String computerPlay = ""; //Computer's play -- "R", "P", or "S" int computerInt; //Randomly generated number used to determine //computer's play String response; int rock = 1; int paper = 2; int scissors = 3; int rock1 = 10; int paper1 = 20; Scanner owo = new Scanner(System.in); Random generator = new Random(); System.out.println("Hey, let's play Rock, Paper, Scissors!\n" + "Please enter a move.\n" + "Rock, Paper or Scissors"); //Both inputs are going to be on the same line System.out.println(); System.out.print("Enter your play: "); personPlay = owo.next(); //Make player's play uppercase for ease of comparison personPlay = personPlay.toUpperCase(); //Using the numbers above we put them into our code //make sure you put inputs for non-valid inputs // like for example, "lol and rock" nah-uh, big no no // All greater than first then least if (rock==rock) { System.out.println("tie :p"); } else{ System.out.println("Invaild input, Please refresh and try again"); } if (paper1>rock){ System.out.println("Paper wins!:D"); } if (scissors>paper){System.out.println("Scissors wins!:D"); } if (rock1>scissors){System.out.println("Rock wins!:D"); } if (scissors==scissors){System.out.println("It's a tie! :p"); } if (paper==p

13th Sep 2021, 4:34 PM
Err3c
Err3c - avatar
2 Respostas
+ 4
Create a code in code playground , put the whole code inside it and then share the link with us.
13th Sep 2021, 4:57 PM
Abhay
Abhay - avatar
+ 3
The code is incomplete, please paste your code to code playground, and link it here. I can see that you didn't use else if statement.
13th Sep 2021, 4:55 PM
Rellot's screwdriver
Rellot's screwdriver - avatar