Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Game Paper, Scissors,rock Java program using Array, so that: 1 - It uses a looping mechanism. It will play the game at least once and

Game Paper, Scissors,rock Java program using Array, so that:

1 - It uses a looping mechanism. It will play the game at least once and print the outcome. Then, it will then ask the user if they would like to play again (Yes or No). If they choose Yes, then loop again to play the game again. If they choose No, then quit the program. Be sure to handle upper / lower case. 2 The code will use a one-dimensional array that lists the 3 choices we have: 0 is scissors, 1 is rock, and 2 is paper. We can have the number (0, 1, 2) correspond to the index of the array: // possible choices final static String[] choices = {"scissors", "rock", "paper"}; 3 - The code will use a two-dimensional array to keep track of the rules of the game. This will replace the need of a complex and/or nested if statement to determine who won the game. Design the two-dimensional array and then implement it in the code. The 2D array could hold the outcome, in String form, that can be used to determine what message should be displayed. The rows represent what the user chose and columns represent what the computer chose. Sample Output: Enter 0 for scissors, 1 for rock, or 2 for paper: 0 The human chose scissors. The computer chose paper. Human wins. Do you want to play again? Yes Enter 0 for scissors, 1 for rock, or 2 for paper: 2 The human chose paper. The computer chose scissors. Computer wins. Do you want to play again? Yes Enter 0 for scissors, 1 for rock, or 2 for paper: 1 The human chose rock. The computer chose rock. It is a draw.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago