Program Help Needed!!

Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions:
a.) voidgetScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered.
b.) voidcalcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores.
c.) int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, who uses the function to determine which of the five scores to drop.
// Input validation // DO NOT ACCEPT TEST SCORES LOWER THAN 0 OR HIGHER THAN 100



This is what is got so far...need help on voidcalcAverage...



#include "stdafx.h"
#include <iostream>
using namespace std;

void getScore(int &, int &, int &, int &, int &);
void calcAverage(double, double, double, double, double);
int findLowest();

int main()
{
int s1, s2, s3, s4, s5;

cout << "I am staring in function main.\n";

getScore(s1, s2, s3, s4, s5);
cout << "Now back in main. The 5 test score are: " << endl;
cout << s1 << endl << s2 << endl << s3 << endl << s4 << endl << s5 << endl;

cout << "Now back in main." << endl;
cout << "The average of the 4 highest test scores is: ";
calcAverage(s1, s2, s3, s4, s5);

return 0;
}

void getScore(int &s1, int &s2, int &s3, int &s4, int &s5)
{
cout << "Enter 5 test scores: ";
cin >> s1 >> s2 >> s3 >> s4 >> s5;

while (s1 < 0 || s1 > 100 && s2 < 0 || s2 > 100 && s3 < 0 || s3 > 100 &&
s4 < 0 || s4 > 100 && s5 < 0 || s5 > 100)
{
cout << "Invaild value entered !!" << endl;
cout << "Please enter a value between 0 through 100: ";
cin >> s1 >> s2 >> s3 >> s4 >> s5;
}

}

void calcAverage(double s1, double s2, double s3, double s4, double s5)
{

cout << (s1 + s2 + s3 + s4 + s5) / 4 ;

}
Last edited on
closed account (z05DSL3A)
This post is posted across multiple forums, please respond in the following one:

http://www.cplusplus.com/forum/beginner/1817/
Topic archived. No new replies allowed.