SOURCE FILE: gradeComments.cpp



/*

      This program will input a grade and output a comment on the grade.

*/

#include <iostream>
#include <iomanip>

using namespace std ;

int main ()
{
       // Prototypes
  char getGrade() ;
  void makeComment(char) ;

  char grade = getGrade() ;

  makeComment(grade) ;
   
  return 0 ;
}

/* ************************************************************ */
/*                        GET GRADE                             */
/* ************************************************************ */
/* Prompt for the user to enter a grade A,B,C,D, or F.  Return the grade to
   the caller. */
char getGrade()
{
   char userInput ;
   do
   {
       cout << 
       "Please enter one of the following letter grades: A,B,C,D, or F ==> ";
       cin >> userInput ;
   }
   while (
           userInput != 'A' &&
           userInput != 'B' &&
           userInput != 'C' &&
           userInput != 'D' &&
           userInput != 'F'
         ) ;
   return userInput ;	 
}


/* ************************************************************ */
/*                       MAKE COMMENT                           */
/* ************************************************************ */
/*
    Make a comment, based on the grade that is input.
*/
void makeComment(char grade) 
{
   cout << "You received a grade of " << grade
        << "." << endl ;
   switch (grade)
   {
      case 'A':
      case 'B': cout << "That was good work!" << endl ; break ;
      case 'C': cout << "That was average work." << endl ; break ;
      case 'D': 
      case 'F': cout << "That was poor work." << endl ; break ;
   }
}

/* ************************************************************ */
/*                                                              */
/* ************************************************************ */