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).
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
Related questions
Question
Help please this is the code so far, but I need help finding the average of the numbers inputted by the user
CODE:
prompt: .asciiz "Enter the number of real numbers: "
.text
.globl main
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 5
syscall
move $t0, $v0
li $t1, 0
loop:
beq $t0, $t1, end
li $v0, 6
syscall
addi $t1, $t1, 1
j loop
end:
li $v0, 10
syscall
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr