The following C++ program is given as the structural specification of the MIPS p
ID: 3653017 • Letter: T
Question
The following C++ program is given as the structural specification of the MIPS program that you will write. You must follow the key data structure (use an array of floating-point of numbers) and program structure (use all the procedures defined in the program) to implement your MIPS program. The difference between this program and the program in question is of using floating-point number in the array and use floating-point operations. float static nArray[50]; //Declare an array of 50 void static setArray() // Initialize the array { for (int i = 0; i<50; i++) { nArray[i] = i * 0.3; cout.precision(2); } }; float static addEven(int n) // Add even numbers in the array { cout.precision(2); cout << "n = " << n << endl; if (n == 0) return nArray[0]; else return nArray[n] + addEven(n-2); } float static addAll(int n) // Add all numbers in the array { cout.precision(2); cout << "n = " << n << endl; if (n == 1) return nArray[1]; else return nArray[n] + addAll(n-1); } float static addEvenAll(int n) // Call different procedures depending on the value of n { if (n % 2 == 0) // Cast n into integer and then test if n is an even number return addEven(n); else return addAll(n); } void main() // main function is the entry point of the program { float n, sum; setArray(); // initialize the array cout << "If an odd number is entered, add numbers will be added, otherwise, even numbers will be added." << endl; cout << "Please enter a number between 1 and 49. :" << endl; cin >> n; while ((n < 1) || (n > 49)) // check the validity of the input { cout << "Please enter a number between 1 and 49. :" << endl; cin >> n; } sum = addEvenAll(n); cout.precision(2); cout << "sum = " << fixed << sum << endl; }; An example of the output would be: Enter a numer 1-49 n=5 n=4 n=3 n=2 n=1 sum=4.5 please help! thank youExplanation / Answer
Are you in Dr. Chens class?