Write a MIPS assembly program that asks a user to input a list of real numbers (represented as single precision floating point numbers) and then prints out the average and variance of those numbers. The program should first ask the user how many numbers they wish to enter and validate that this number is greater than 1. Assuming the user inputs n, then the program should perform n system calls to collect these numbers. Assuming the numbers are given by x1, x2, by: 18 = 1 n n, then the average and variance are given IM³ æk and 1 n var(x) = n - 1 (2kg) k=1 Note how the variance depends on first calculating the average. As an example, if the user specifies 4 numbers and then enters 1.0, 1.5, 2.5, and 3.0, then the average is (1.0 + 1.5 + 2.5 + 3.0) / 4 = 2.0. The variance is ((1.0 - 2.0)2 + (1.5 - 2.0)² + (2.5 - 2.0)² + (3.0 - 2.0)²) / 3 = (1 + 0.25 +0.25 + 1) / 3 = 2.5/3 = 0.83333. Hint: You can use an array to help store the numbers if you would like (although there is a more mathy way to calculate the variance without having to store the numbers).

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter2: Problem Solving Using C++using
Section2.4: Arithmetic Operations
Problem 6E
icon
Related questions
Question

Need help writing 

this code please I am not sure what variables to use

 

Write a MIPS assembly program that asks a user to input a list of real numbers
(represented as single precision floating point numbers) and then prints out the average and
variance of those numbers. The program should first ask the user how many numbers they wish
to enter and validate that this number is greater than 1. Assuming the user inputs n, then the
program should perform n system calls to collect these numbers.
Assuming the numbers are given by x1, x2,
by:
18
=
1
n
n, then the average and variance are given
IM³
æk
and
1
n
var(x)
=
n
- 1
(2kg)
k=1
Note how the variance depends on first calculating the average.
As an example, if the user specifies 4 numbers and then enters 1.0, 1.5, 2.5, and 3.0, then the
average is (1.0 + 1.5 + 2.5 + 3.0) / 4 = 2.0. The variance is
((1.0 - 2.0)2 + (1.5 - 2.0)² + (2.5 - 2.0)² + (3.0 - 2.0)²) / 3 = (1 + 0.25 +0.25 + 1) / 3 = 2.5/3 =
0.83333.
Hint: You can use an array to help store the numbers if you would like (although there is a more
mathy way to calculate the variance without having to store the numbers).
Transcribed Image Text:Write a MIPS assembly program that asks a user to input a list of real numbers (represented as single precision floating point numbers) and then prints out the average and variance of those numbers. The program should first ask the user how many numbers they wish to enter and validate that this number is greater than 1. Assuming the user inputs n, then the program should perform n system calls to collect these numbers. Assuming the numbers are given by x1, x2, by: 18 = 1 n n, then the average and variance are given IM³ æk and 1 n var(x) = n - 1 (2kg) k=1 Note how the variance depends on first calculating the average. As an example, if the user specifies 4 numbers and then enters 1.0, 1.5, 2.5, and 3.0, then the average is (1.0 + 1.5 + 2.5 + 3.0) / 4 = 2.0. The variance is ((1.0 - 2.0)2 + (1.5 - 2.0)² + (2.5 - 2.0)² + (3.0 - 2.0)²) / 3 = (1 + 0.25 +0.25 + 1) / 3 = 2.5/3 = 0.83333. Hint: You can use an array to help store the numbers if you would like (although there is a more mathy way to calculate the variance without having to store the numbers).
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr