Problem

a. Write an application that displays the results of a series of 10 coin tosses. Use the...

a. Write an application that displays the results of a series of 10 coin tosses. Use the Math . random () function explained in Appendix D to generate a number between 0 and 1; you will use a statement similar to:

result = Math. random();

After each coin toss, display whether the toss represents "heads" or "tails? If the result is 0.5 or less, the result represents heads; otherwise, it represents tails. After the 10 tosses are complete, display the percentages of heads and tails. Run the application several times until you are confident that the coin tosses occur randomly. Save the file as FlipCoin.java.

b. Modify the application in Exercise 9a so that you generate 1,000 coin tosses and keep track of the heads and tails. Do not display the coin toss result with each flip, but instead display percentages of the heads and tails after the 1,000 coin tosses are complete. Save the file as FlipCoin2.java.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT