Question: could you please try to find what my coding in java program missing so it look like the output! i'm suppose to code RockPaperScissorsEnhance game,

could you please try to find what my coding in java program missing so it look like the output!

i'm suppose to code

RockPaperScissorsEnhance game,

in which the computer randomly chooses rock, paper or scissors(without revealing it).

I already did this :

import java.util.Random;

import java.util.Scanner;

public class rockPaperScissors {

public static void main(String[] args) {

while(true) {

System.out.println("Rock-Paper-Scissors Game");

System.out.println("Please enter your choice.");

System.out.println("Type in 1 for rock, 2 for paper or 3 for scissors, and press enter.");

Scanner choice = new Scanner(System.in);

int rps = choice.nextInt();

Random cChoice = new Random();

int cChoiceRand = cChoice.nextInt(3) + 1;

if(rps<4 && rps>0) {

if (rps == 1)

System.out.println("You chose: Rock");

if (rps == 2)

System.out.println("You chose: Paper");

if (rps == 3)

System.out.println("You chose: Scissors");

if (cChoiceRand == 1)

System.out.println("The computer chose: Rock");

if (cChoiceRand == 2)

System.out.println("The computer chose: Paper");

if (cChoiceRand == 3)

System.out.println("The computer chose: Scissors");

System.out.println("The result is:");

if (rps == cChoiceRand)

System.out.println(" a tie");

if (rps == cChoiceRand+1)

System.out.println(" you win");

if (rps == cChoiceRand-1)

System.out.println(" the computer wins");

if (rps==1 && cChoiceRand==3)

System.out.println(" you win");

if (rps==3 && cChoiceRand==1)

System.out.println(" the computer wins");

System.out.println(" GoodBye! ");

System.out.println("--------------------------------------------------------------------");

}

if (rps>3 || rps<1) {

System.out.println("That is not a choice. Please type in 1 for rock, 2 for paper or 3 for scissors, and press enter.");

System.out.println("------------------------------------------------------------------------------------------------");

}

}

}

}

but the New

Output should look like this with Valid inputs:

********Rock Paper Scissors***************

Enter one of the following:

-- Rock

-- Paper

--Scissors

Rock

You picked rock

Computer picked rock

Winner: Tie

Do you want to play again : Y/N ?

y

********Rock Paper Scissors***************

Enter one of the following:

-- Rock

-- Paper

--Scissors

Scissors

You picked scissors

Computer picked rock

Winner: Computer

Do you want to play again : Y/N ?

y

********Rock Paper Scissors***************

Enter one of the following:

-- Rock

-- Paper

--Scissors

paper

You picked paper

Computer picked rock

Winner: You

Do you want to play again : Y/N ?

N

You won 1 times.

You lost 1 times.

We tied 1 times.

Good Bye!

********Rock Paper Scissors***************

Enter one of the following :

-- Rock

-- Paper

--Scissors

Scissors

You picked scissors

Computer picked paper

Winner: You

Do you want to play again : Y/N ?

y

********Rock Paper Scissors***************

Enter one of the following :

-- Rock

-- Paper

--Scissors

rack

Invalid Choice!

Do you want to play again : Y/N ?

y

********Rock Paper Scissors***************

Enter one of the following :

-- Rock

-- Paper

--Scissors

Rock

You picked rock

Computer picked paper

Winner: Computer

Do you want to play again : Y/N ?

n

You won 1 times.

You lost 1 times.

We tied 0 times.

Goodbye!!

How should i code it so it look like the output?please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!