Question: JAVA PROGRAMMING You are required to create a simple slot machine with three slots. Each slot will generate a random number from 1 to 9.

JAVA PROGRAMMING

You are required to create a simple slot machine with three slots. Each slot will generate a random number from 1 to 9. The user will start with 100 coins and can bet any number of coins per slot pull. The payouts are defined as follows:

If 2 slots equal each other the user wins 2x the bet.

If 3 slots equal each other the user wins 10x the bet.

If 0 slots equal the user loses the bet.

The game continues until the user is out of coins or the user chooses to quit the game by entering 0.

Your program checks to be sure that the user bets appropriate amount of coins for a play (i.e., bet has to be within current amount).

Sample inputs/outputs

You have 100 coins.

Enter 0 to exit or any other number to play that many coins per spin

10

Spin: 1 7 7

You won 20 coins! You now have 120 coins.

Enter 0 to exit or any other number to play that many coins per spin

1000

Your bet cannot exceeds 120 coins.

Enter 0 to exit or any other number to play that many coins per spin

-1

Your bet cannot be negative.

Enter 0 to exit or any other number to play that many coins per spin

110

Spin: 9 1 2

You lost 110 coins. You now have 121000 coins.

Enter 0 to exit or any other number to play that many coins per spin

10

Spin: 4 5 6

You ran out of coins. Thanks for playing.

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 Databases Questions!