Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In java please Code Write a Java program called Flip Your class only needs a main method and will use one command line argument. In
In java please
Code Write a Java program called Flip Your class only needs a main method and will use one command line argument. In your main method, create a Random object and use it to generate pseudorandom numbers double ) to simulate a coin flip. The command line argument (a number between 0 and 1) will specity the bias of your flip towards "heads". For example, java Flip 8.5 will simulate a fair coin which returns heads 50% of the time and tails 50% of the time, while java Flip 0.3 will simulate an unfair coin that returns a heads 30% of the time and tails 70% of the time. Your program should generate 100 pseudorandom numbers (coin flips) and count how many times heads and how many times tails was found. The program should output something like 28 heads, 72 tails, bias 0.3 when running java Flip 0.3 The nextDouble) method in the Random class returns a number in the range [0.0,1.0) just like Math.random)). If we assume all numbers in this range are equally likely to be returned, then we can simulate the coin fip by comparing the output with the bias. For example, suppose r is the random number returned and p is the probability we want for heads. If rStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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