Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions