Question: Make changes to H3_Q3.java to accomplish the following tasks. a. The le H3_Q3.java contains code to generate a random oating-point number between 0 an 1.
Make changes to H3_Q3.java to accomplish the following tasks. a. The le H3_Q3.java contains code to generate a random oating-point number between 0 an 1. Add a loop that generates 10,000 such random numbers. 1 b. For the 10,000 random numbers generated in (a), add code that counts the total number of times that the random value generated exceeds 0.75. Print this total to the screen with an appropriate label. c. For the 10,000 random numbers generated in (a), add code that counts the total number of times that the random value generated is in either of the following ranges: [0.0,0.2] or [0.8,1.0]. Print this total to the screen with an appropriate label. d. Writealoopthecontinuestogeneraterandomoating-pointnumbersbetween0an1untiltherandom value generated exceeds 0.9. Print out the number of times the loop was executed with an appropriate label.
import java.util.Random; public class H3_Q3 { public static void main(String args[]) { //double randomNumber; //stores randomly generated number between 0 and 1 //add loop around statement below to generate 10,000 random numbers randomNumber = Math.random(); //generates random number between 0 and 1 and stores it in randomNumber
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
