Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program which simulates the toss of a coin. Whenever a coin is tossed the result will be either a head or tail. Prompt

Write a program which simulates the toss of a coin. Whenever a coin is tossed the result will be either a head or tail. Prompt the user by using a dialog window to enter an H for heads or T for tails. Validate input. Make sure that both an upper case and lower case letter will be accepted. Have the computer generate a random number so that the probability of either a head or tail is equally possible. Display the outcome of the coin toss using a window, either You Win! or Computer Wins as a result of the users guess compared to the random number generated. Use loops for input validation and to allow for multiple flips of the coin. The user enters either Y or y to continue the program. Keep track of the number of wins and losses. Display the summary when the user decides to quits the program. Example of the output is shown below:Write a program which simulates the toss of a coin. Whenever a coin is tossed the result will be either a head or tail. Prompt the user by using a dialog window to enter an H for heads or T for tails. Validate input. Make sure that both an upper case and lower case letter will be accepted. Have the computer generate a random number so that the probability of either a head or tail is equally possible. Display the outcome of the coin toss using a window, either You Win! or Computer Wins as a result of the users guess compared to the random number generated. Use loops for input validation and to allow for multiple flips of the coin. The user enters either Y or y to continue the program. Keep track of the number of wins and losses. Display the summary when the user decides to quits the program. Example of the output is shown below:

This should be done in basic java language using simple control structures and input validation. This is for an intro to programming course in Java

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

Students also viewed these Databases questions