Question: Write a program that generates 100 random numbers between 1 and 1000. Then, the program should calculate the sum, average, standard deviation, minimum, and maximum

Write a program that generates 100 random numbers between 1 and 1000. Then, the program should calculate the sum, average, standard deviation, minimum, and maximum of all the numbers and output them.

randNum = rand # => random number between 0.0 and 1.0

randNum = 1 + rand(1000)

Your program should generate 100 random numbers in the range 1 to 1000 and store them in an array. Then, your program should calculate the sum, average, standard deviation, minimum, and maximum of all the numbers.

One further requirement: you must store the sum, average, standard deviation, minimum and maximum in a hash called stats. In other words, at the end of your program, you should have a hash variable that looks like this: stats = {:sum => 123, :avg => 456, :std_dev => 789, :min => 3, :max => 9

Then, you must iterate over that hash in order to output all the values accordingly.

Program should run like this:

$Generating 100 random numbers... Here are the results: sum: 247563 average: 672 standard deviation: 39 minimum: 2 maximum: 974 $

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!