Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 21: Math.random( ) is a method in the Java library that computes a random double value between 0 and 1. For example, the statement

Exercise 21: Math.random( ) is a method in the Java library that computes a random double value between 0 and 1. For example, the statement double x = Math.random(); assigns to the variable x a random double between 0 and 1. Write a program that tests how well Math.random() works. More precisely, write a program that calls Math.random() 1,000 times to create 1,000 values, keeping track of how many of them are greater than 0.5, and then prints out the result. Your program should theoretically print out a number very close to 500.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions