Explanation of Solution
A loop that fills an array values with ten random numbers between 1 and 100:
Consider the below “for” loop that fills an array “values” with ten random numbers between 1 and 100:
//create and declare the array with size 10
int[] values = new int[10];
//loop to generate random values between 1 and 100
for (int i = 0; i < 10; i++)
{
/*compute and stores the random values in the position i */
values[i] = (int) (Math...
Explanation of Solution
The two nested loops that fill values with ten different random numbers between 1 and 100:
Consider the below two nested loops that fills “values” with ten random numbers between 1 and 100:
//Declare an integer variable to store random numbers
int[] values = new int[10];
//Outer loop to generate ten random numbers
for (int i = 0; i < 10; i++)
{
//Generate random numbers and store into the variable
values[i] = (int) (Math.random() * 100 + 1);
/*Declare and initialize a variable to count random numbers */
int count = 0;
/*Inner loop to check whether the number is already generated or not */
for (int j = 0; j < i; j++)
{
/*Check whether the generated value is matches with the existing list or not */
if (values[j] == values[i])
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
Big Java Late Objects
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education