Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Question

Using this MATCH function in cell G 3 , day 1 9 returns the row

Answered: 1 week ago