Link to home
Start Free TrialLog in
Avatar of TheChos
TheChos

asked on

Java help

I need help finishing up my program, the problem is this, Remember the childhood game “Rock, Paper, Scissors”? It is a two-player game in which each person simultaneously chooses either rock, paper, or scissors. Rock beats scissors but loses to paper, paper beats rock but loses to scissors, and scissors beats paper but loses to rock. The following code prompts player 1 and player 2 to each enter a string: rock, paper, or scissors. Finish the code by adding nested if statements to appropriately report “Player 1 wins”, “Player 2 wins”, or “It is a tie.”

I already have this :

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, scissors, or paper:");  
    String player1 = scan.next().toLowerCase();
    System.out.println("Player 2: Choose rock, scissors, or paper:");


Can you help me?
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

What you already have is what the assignment gave you. You haven't done anything yet.
We cannot do your homework for you, but we can help; however, in order to do that, we need to know what is blocking you. What is it that you do not know how to do?
So you are supposed to be writing "nested ifs." Can you write the logic using pseudo code? (i.e. English but in a code looking way something like
if player1 chose rock
{
   if player2 chose paper
  ...etc.
Avatar of TheChos
TheChos

ASKER

thats what I need help with I do not quite understand how to do if player1 chose rock part and how its set up
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheChos

ASKER

Thank you this helped me alot