Question: Simple Java Coin Toss Program Write a simple Java Program Using this algorithm. Initialize the heads count to zero Initialize the tail count to zero

Simple Java Coin Toss Program

Write a simple Java Program Using this algorithm.

Initialize the heads count to zero Initialize the tail count to zero

For 1000 times

get a random number between 0 and 1

if the random number is greater than 0.5

consider this as a head and

add one to the heads count

else

consider this as a tail and

add one to the tails count

end if

enf for

calculate the percentage of heads as

the number of heads divided by 1000 X 100% calculate the percentage of tails as

the number of tails divided by 1000 X 100% print the percentage of heads and tails obtained

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!