Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**IN JAVA** Make a Game - Game Strategy The program and the user alternate turns, picking up one, two, or three straws on each turn.

**IN JAVA**

Make a Game

-Game Strategy

The program and the user alternate turns, picking up one, two, or three straws on each turn.

The program goes first.

The player to pick up the last straw loses.

-Game process

Your program should start by generating and displaying a random integer (which represents the number of straws) between 10 and 20 inclusive.

If this number is 1 more than a multiple of 4, add 1. For example, if the random integer is 20, then start with 20 straws. However, if the random integer is 17 (which is 1 more than a multiple of 4), start with 18.

On a users turn, your program should prompt for, read in, and process the users input (which should be 1, 2, or 3the number of straws to pick up).

On the programs turn, it should determine its move by generating a random number between 1 and 3. At the end of each game, your program should display

Do you want to play another game?

It should then read in the users yes/no response, and proceed accordingly. Use a dowhile loop to control the repetition of games.

If either a users move or the programs move is greater than the number of straws, then all the remaining straws should be picked up, resulting in a loss. For example, if there are 2 straws left, and the users move is 3, the remaining 2 straws should be picked up, causing the user to lose.

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions