Answer to Question #271687 in C++ for Amanda

Question #271687

A student did 8 units in an exam and got different marks in each of the exam papers. He intends to calculate his total, mean score and exams decision for the exams using a program written in C++.

1. Assign 8 scores to the student in a one-dimensional array.

2. Declare a function that takes an array of the student’s scores as a parameter and calculates both the total and the mean score.

3. Pass the mean score from (2) above into another function by reference, that computes whether the student has passed or not given that a pass is 50 – 100 while a fail is 0 – 49.99

Write a C++ program that will compute the above.


1
Expert's answer
2021-11-26T07:11:12-0500
#include <iostream>
using namespace std;
void Mean(float scores[], float &total, float &mean){
    total = 0;
    for(int i = 0; i < 8; i++){
        total += scores[i];
    }
    mean = total / 8;
}
void passFail(float &mean){
    if(mean < 50) cout<<"Fail\n";
    else cout<<"Pass\n";
}
int main(){
    float total, mean, scores[] = {55, 72, 46, 50, 80, 40, 44, 69};
    Mean(scores, total, mean);
    cout<<"Total: "<<total<<endl;
    cout<<"Mean: "<<mean<<endl;
    passFail(mean);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS