Question: java please E 7.1 Write a program that initializes an array with ten random integers (1 - 100) and then prints four lines of output,
E 7.1 Write a program that initializes an array with ten random integers (1 - 100) and then prints four lines of output, containing a. Every element. Notes for E7.1 A. How to use Java Math.random() method: The java.lang. Math.random() is used to return a pseudorandom double type number greater than or equal to 0.0 and less than 1.0. The default random number always generated between 0 and 1. If you want to specific range of values, you have to multiply the returned value with the magnitude of the range. For example, if you want to get the random number between 0 to 20, the resultant address has to be multiplied by 20 to 8 the desired result / Generate random number between 0 to 20 double a = Math.random() * 20; double b - Math.random() * 20; # To Generate random number between 0 to 100 double dblNum = Math.random() * 100 // To Generate random number between 0 to 100 as integer, convert the double number to an integer int intNum (int) (Math.random() * 100 // To Generate random integer number between 1 to 100. plus 1 int intNum = (int) (Math.random() 100+ 1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
