Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

http://www.samkass.com/theories/RPSSL.html Sample runs (user input in color): We

ID: 675520 • Letter: H

Question

http://www.samkass.com/theories/RPSSL.html

Sample runs (user input in color):

Welcome to the game of Rock Paper Scissors Lizard Spock

Here are the rules:
    Scissors cuts Paper
    Paper covers Rock
    Rock crushes Lizard
    Lizard poisons Spock
    Spock smashes Scissors
    Scissors decapitates Lizard
    Lizard eats Paper
    Paper disproves Spock
    Spock vaporizes Rock
    (and as it always has) Rock crushes scissors

Ready? Then let's begin!

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): lizard

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

    Lizard poisons Spock; Player 1 wins
    
Play again (yes/no)? yes

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): rock

    Spock vaporizes rock; Player 1 wins
    
Play again (yes/no)? yes

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

    It's a draw
    
Play again (yes/no)? yes

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): lizard

    Lizard poisons Spock; Player 2 wins
    
Play again (yes/no)? yes

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): Sock
Invalid choice "sock"; try again.
Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): Spock

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): paperr
Invalid choice "paperr"; try again.
Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): paper

    Paper disproves Spock; Player 2 wins
    
Play again (yes/no)? yes

Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): scissor
Invalid choice "scissor"; try again.
Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): scissors

Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): SPock

    Spock smashes scissors; Player 2 wins
    
Play again (yes/no)? no

^^

I want the code that help me get the above resulte for A to Z So I can run the code using Netbeans program. it is for CPS class (java)

Explanation / Answer

import java.io.*;
import java.util.Scanner;

public class ScissorRockPaperSpockLizard
{
public static void main(String[] args)
{
String player1, player2, choice;
Scanner in = new Scanner(System.in);
System.out.println("Welcome to the game of Rock Paper Scissors Lizard Spock");
System.out.println("Here are the rules:");
System.out.println("Scissors cuts Paper");
System.out.println("Paper covers Rock");
System.out.println("Rock crushes Lizard");
System.out.println("Lizard poisons Spock");
System.out.println("Spock smashes Scissors");
System.out.println("Scissors decapitates Lizard");
System.out.println("Lizard eats Paper");
System.out.println("Paper disproves Spock");
System.out.println("Spock vaporizes Rock");
System.out.println("(and as it always has) Rock crushes scissors");
System.out.println("Ready? Then let's begin!");
while(true)
{
System.out.print("Player 1, enter your choice ( rock, paper, scissors, lizard, spock ): ");
player1 = in.next();
System.out.print("Player 2, enter your choice ( rock, paper, scissors, lizard, spock ): ");
player2 = in.next();
  
if(player1.toLowerCase().equals("rock") && player2.toLowerCase().equals("rock"))
System.out.println("It's a draw.");
else if(player1.toLowerCase().equals("rock") && player2.toLowerCase().equals("paper"))
System.out.println("Paper covers Rock. Player 2 wins.");
else if(player1.toLowerCase().equals("rock") && player2.toLowerCase().equals("scissors"))
System.out.println("Rock crushes Scissors. Player 1 wins.");
else if(player1.toLowerCase().equals("rock") && player2.toLowerCase().equals("lizard"))
System.out.println("Rock crushes Lizard. Player 1 wins.");
else if(player1.toLowerCase().equals("rock") && player2.toLowerCase().equals("spock"))
System.out.println("Spock vaporizes Rock. Player 2 wins.");
else if(player1.toLowerCase().equals("paper") && player2.toLowerCase().equals("rock"))
System.out.println("Paper covers Rock. Player 1 wins.");
else if(player1.toLowerCase().equals("paper") && player2.toLowerCase().equals("paper"))
System.out.println("It's a draw.");
else if(player1.toLowerCase().equals("paper") && player2.toLowerCase().equals("scissors"))
System.out.println("Scissors cuts Paper. Player 2 wins.");
else if(player1.toLowerCase().equals("paper") && player2.toLowerCase().equals("lizard"))
System.out.println("Lizard eats Paper. Player 2 wins.");
else if(player1.toLowerCase().equals("paper") && player2.toLowerCase().equals("spock"))
System.out.println("Paper disproves Spock. Player 1 wins.");
else if(player1.toLowerCase().equals("scissors") && player2.toLowerCase().equals("rock"))
System.out.println("Rock crushes Scissors. Player 2 wins.");
else if(player1.toLowerCase().equals("scissors") && player2.toLowerCase().equals("paper"))
System.out.println("Scissors cuts Paper. Player 1 wins.");
else if(player1.toLowerCase().equals("scissors") && player2.toLowerCase().equals("scissors"))
System.out.println("It's a draw.");
else if(player1.toLowerCase().equals("scissors") && player2.toLowerCase().equals("lizard"))
System.out.println("Scissors decapitates Lizard. Player 1 wins.");
else if(player1.toLowerCase().equals("scissors") && player2.toLowerCase().equals("spock"))
System.out.println("Spock smashes Scissors. Player 2 wins.");
else if(player1.toLowerCase().equals("lizard") && player2.toLowerCase().equals("rock"))
System.out.println("Rock crushes Lizard. Player 2 wins.");
else if(player1.toLowerCase().equals("lizard") && player2.toLowerCase().equals("paper"))
System.out.println("Lizard eats Paper. Player 1 wins.");
else if(player1.toLowerCase().equals("lizard") && player2.toLowerCase().equals("scissors"))
System.out.println("Scissors decapitates Lizard. Player 2 wins.");
else if(player1.toLowerCase().equals("lizard") && player2.toLowerCase().equals("lizard"))
System.out.println("It's a draw.");
else if(player1.toLowerCase().equals("lizard") && player2.toLowerCase().equals("spock"))
System.out.println("Lizard poisons Spock. Player 1 wins.");
else if(player1.toLowerCase().equals("spock") && player2.toLowerCase().equals("rock"))
System.out.println("Spock vaporizes Rock. Player 1 wins.");
else if(player1.toLowerCase().equals("spock") && player2.toLowerCase().equals("paper"))
System.out.println("Paper disproves Spock. Player 2 wins.");
else if(player1.toLowerCase().equals("spock") && player2.toLowerCase().equals("scissors"))
System.out.println("Spock smashes Scissors. Player 1 wins.");
else if(player1.toLowerCase().equals("spock") && player2.toLowerCase().equals("lizard"))
System.out.println("Lizard poisons Spock. Player 2 wins.");
else if(player1.toLowerCase().equals("spock") && player2.toLowerCase().equals("spock"))
System.out.println("It's a draw.");
else
System.out.println("Invalid choice. Try Again.");

  
System.out.print("Play again (yes/no)? ");
choice = in.next();
if(choice.equals("no"))
System.exit(0);
}
}
}