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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started