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:

Recommended Answers

All 3 Replies

You have to write two more functions to compute the total marks and the highest marks.

I can suggest the prototypes as:

void totalmarks( int &currentTotal, int &marks );
void highestmarks( int &currentHighest, int marks );

Its really simple to implement these functions. Hope that helps.

for (int i = 1; i <= 3; i++)
  {
  InputName( name,  mark);
  symbol( sym, mark);
  displayMessage(sym, name);
 
 
  }

You've called your symbol function, but you haven't done anything with the returned value.

If you don't wish to use the return value, then you will need to pass sym by reference, ie

char symbol(char & symbolP, int markP)

is there only one mark per person???

if not you will have to add your marks ... otherwise its ok...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.