I need to write program with five different functins. Teacher wants to input the names and exam marks for her students. She wants to determine symbol (A-F) she should assign to each. She wants to display the symbol as well as an appropriate message. Finally she would like to display the highest mark as well as the averae mark of the class. So far I did this:
1st function to input nameAndMark
void InputName(string & nameP, int & markP)
{
cout << "Type the student's name: ";
cin >> nameP;
cout << "Enter the stuedent's mark: ";
cin >> markP;
}
2nd function to determine the symbol
char symbol(char symbolP, int markP)
{
if (markP > 0 && markP < 40)
return symbolP = 'F';
else if (markP >= 40 && markP < 50)
return symbolP = 'E';
else if (markP >= 50 && markP < 60)
return symbolP = 'D';
else if (markP >= 60 && markP < 70)
return symbolP = 'C';
else if (markP >= 70 && markP < 80)
return symbolP = 'B';
else if (markP >= 80 && markP <= 100)
return symbolP = 'A';
else
cout << "The range of mark is 0 - 100" << endl;
}
3rd function to display message
void displayMessage(char symbolP, string nameP)
{
switch(symbolP)
{
case 'F':
cout << "Unfortunately you will have to repeat the course, " << nameP << "." << endl;
break;
case 'E':
cout << "You nearly passed. Keep trying, " << nameP << "." << endl;
break;
case 'D':
cout << "Congratulations! You passed, " << nameP << "." << endl;
break;
case 'C':
cout << "Congratulations! You got 60%, " << nameP << "." << endl;
break;
case 'B':
cout << "Well done! Congratulations, " << nameP << "." << endl;
break;
case 'A':
cout << "Excellent! Congratulations, " << nameP << "." << endl;
break;
}
}
4th main function
int main() {
string name;
int mark, totalMark, highestMark;
float averagMark;
char sym;
totalMark = 0;
for (int i = 1; i <= 3; i++)
{
InputName( name, mark);
symbol( sym, mark);
displayMessage(sym, name);
}
cout << endl;
cout << "Highest mark is: ";
return 0;
}
But its all I could do. Please help me. Tell me what I am doing wrong so far that my functions don't work properly?
Need urgante help. Today its my finale day.:sweat: