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

Create a JavaFX application using Eclipse Java Mars that lets the user play the

ID: 3690738 • Letter: C

Question

Create a JavaFX application using Eclipse Java Mars that lets the user play the game of rock, paper, scissors against the computer. The program should work as follows.

When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)

The user selects his or her choice of rock, paper, or scissors by clicking a Button. An image of the user’s choice should be displayed in an ImageView component.

An image of the computer’s choice is displayed.

A winner is selected according to the following rules:

If one player chooses rock and the other player chooses scissors, then rock wins.

(Rock smashes scissors.)

If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cut paper)

If one player chooses paper and the other player chooses rock, then paper wins.

(Paper wraps rock)

If both players make the same choice, the game must be played again to determine the winner.

Explanation / Answer

Ans;

   compch = mod( parseint(randnumb),10);}

int userch = s.nextInt();

}

/// please use the following logic by substituting the values as generated above

If num == 1 Then

                        Set comp = rock

            Else If num == 2 Then

                        Set comp = paper

            Else If num == 3 Then

                        Set comp = scissors

            End If

//Read the players choice and put it in plyr

            Display Please enter your choice.

            Input plyr

//Display computers choice

            Display Computer has chosen: , comp

//Compare with three possible choices of comp

//that of three possible choices of plyr, and provide

//a message accordingly

If comp == rock Then

            If plyr == rock Then

                        Display Play again.

            Else If plyr == paper Then

                        Display You won.

            Else If plyr == scissors Then

                        Display Computer won.

End IF

Else If comp == paper Then

            If plyr == rock Then

                        Display Computer won.

            Else If plyr == paper Then

                        Display Play again.

            Else If plyr = = scissors Then

                        Display You won.

End If

Else If comp == scissors Then

            If plyr == rock Then

                        Display You won.

            Else If plyr == paper Then

                        Display Computer won.

            Else If plyr = = scissors Then

                        Display Play again.

            End If

End If

//The loop iterates until both players choice is different

while comp == plyr