Question: Create a program that accepts as user input 1 for heads, 2 for tails and any other numeric value to exit. You must use do

Create a program that accepts as user input 1 for heads, 2 for tails and any other numeric value to exit. You must use do while loop. You must use the same single variable to control your loop and also to accept the users guesses. At the end you will add up the total number of times the user guessed, the number of times the computer won and the number of times the user won. As shown in the sample output user should be allowed to exit without playing.

Hint: Math.random() method will be very useful here. You may want to use break to exit without playing.

Create a program that accepts as user input 1 for heads, 2

HeadsORTails Java Applicationl C:Program FilesJava idkl.8.0 1441biniavaw Enter 1 for HEAD 2 for TAIL Computer wins Enter 1 for HEAD 2 for TAIL; any other number to exit You win Enter 1 for HEAD 2 for TAIL; any other number to exit You win Enter 1 for HEAD 2 for TAIL; any other number to exit Computer wins Enter 1 for HEAD 2 for TAIL; any other number to exit 4 Mr. User played 4 times. Computer won 2 times. Mr. User won 2 times Goodbye HeadsORTails[Java Application] C Enter 1 for HEAD 2 for TAIL Mr. User played e times. Computer won e times. Mr. User won 0 times Goodbye

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!