Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1-Create a one-dimensional array of 99 double values. Then, use a for loop to add a random number from 0 to 100 to each element

1-Create a one-dimensional array of 99 double values. Then, use a for loop to add a random number from 0 to 100 to each element in the array. To do that, use the random method of the Math class to get a double value between 0.0 and 1.0 and multiply it by 100

like this

Math.random() * 100

2-Use an enhanced for loop to sum the values in the array. Then, calculate the average value and print that value on the console like this

Average: 50.9526671843517

3-Use the sort method of the Arrays class to sort the values in the array, and print the median value (the 50th value) on the console

like this

Median: 52.18369291650803 -Print the 9th value of the array on the console and every 9th value after that.

like this

position: 9 8.927702403161032

position: 18 14.0531287498060076

...

position: 99 22.471670293184822

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions