rock paper scissor in java

Solutions on MaxInterview for rock paper scissor in java by the best coders in the world

showing results for - "rock paper scissor in java"
Giorgio
16 Sep 2020
1if (personPlay.equals(computerPlay)) {
2   System.out.println("It's a tie!");
3}
4else if (personPlay.equals("R")) {
5   if (computerPlay.equals("S")) 
6      System.out.println("Rock crushes scissors. You win!!");
7   else if (computerPlay.equals("P")) 
8        System.out.println("Paper eats rock. You lose!!");
9}
10else if (personPlay.equals("P")) {
11   if (computerPlay.equals("S")) 
12       System.out.println("Scissor cuts paper. You lose!!"); 
13   else if (computerPlay.equals("R")) 
14        System.out.println("Paper eats rock. You win!!");
15} 
16else if (personPlay.equals("S")) {
17     if (computerPlay.equals("P")) 
18         System.out.println("Scissor cuts paper. You win!!"); 
19     else if (computerPlay.equals("R")) 
20        System.out.println("Rock breaks scissors. You lose!!");
21}
22else 
23     System.out.println("Invalid user input.");
24