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
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