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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started