Design and implement an algorithm to solve this problem; your solution should use user – defined functions. Do not access global variables. Use parameters! (Suggestions: int function to determine lowest of two numbers, void function to print the message) Use function prototypes; the source code for functions should follow the source code for the main function.
Input a student’s full name and four integer scores (you need getline for the name)
Average the scores – drop the lowest grade; round to the nearest integer
Formula to drop the low grade: average = (sum of all 4 scores -low score) / 3
Print out a message that includes the student name, average, and one of the following:
Exceptional for averages >= 95
Passing for 60 <= averages <95
Gotta repeat it for averages < 60.
After your program works correctly for one student, add a loop so the user can process any number of students.
What I have so far.... Please get it to run! I'm stumped!
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
string GetName();
int GetScore();
int LowScore(int, int, int, int);
int GetAverage();
double ComputeAverage ( int, int, int, int );
void printResult (string, double);
int main(int argc, char *argv[])
{
int s1, s2, s3, s4;
int low, score;
string FullName;
char name;
char done = 'n',
g = 1;
double Average;
cin.get();
while(1)
{
FullName = GetName();
s1= GetScore();
s2= GetScore();
s3= GetScore();
s4= GetScore();
Average = ComputeAverage (s1, s2, s3, s4);
printResult( FullName, Average);
FullName.clear();
cout << "Would you like to continue?\n(Y/N)" <<endl;
cin>> done;
system("PAUSE");
return EXIT_SUCCESS;
}
string GetName();
{
char name;
cout<< "Please enter your student's full name.\n" << endl;
//cin.ignore (cin.rdbuf()->in avail());
getline (cin, FullName);
cout<< endl;
return (name);
}
int GetScore();
{
int score;
cout<< "Please enter score. \n";
cin >> score;
cout<< endl;
return (score);
}
int LowScore(int s1, int s2, int s3, int s4);
{
int s1, s2, s3, s4;
if (s1 < s2 && s1 < s3 && s1 < s4)
{return s1;}
else if (s3 < s2 && s3 < s1 && s3 < s4)
{return s3;}
else if (s2 < s1 && s2 < s3 && s2 < s4)
{return s2;}
if (s4 < s2 && s4 < s3 && s4 < s1)
{return s4;}
return (low);
}
double ComputeAverage();
{
int low;
double Average;
low = LowScore(s1, s2, s3, s4);
Average = static_cast<double>((s1 + s2 + s3 + s4 - low)/3.0 +.5);
return (Average);
}
void printResults(string FullName, double Average)
{cout<< "Student's Name: " << name << endl;
cout<< "The average score is: " << Average <<endl;
if(Average >= 95)
{ cout << "Exceptional" << endl;
}
else if (Average >= 60 && Average < 95)
{cout << "Passing" << endl;}
else
cout << "Gotta repeat it" <<endl;
}