Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Intro to Java help?) Write a complete program that plays a coin flipping game, displays the individual flips, reports when a game is LOST or

(Intro to Java help?)

Write a complete program that plays a coin flipping game, displays the individual flips, reports when a game is LOST or WON and shows the number of flips needed to complete the game.

The algorithm is as follows:

Simulate the flip of a coin using a JAVA random number generator.

Flip the coin once to initialize the flip value and print out the flip

Inside of a loop, repeatedly flip the coin until 3 consecutive flips have the same value (3 heads or 3 tails)

Display the flip results after each flip

When the game ends, report the total number of flips

Note: you can use 0 for heads and 1 for tails, but if you have time, add another method that will convert the integers 0 and 1 to the characters H and T

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

More Books

Students also viewed these Databases questions

Question

Find Ix in the network shown. 41x 1 mA

Answered: 1 week ago