home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0908.CPP
-
- // Files used in this example:
- //-------------------------------------------------------------
- // %F,15,EX09081.H%EX09081.H definition of class Grade
- // %F,15,EX09081.CPP%EX09081.CPP members of class Grade
- // EX0908.CPP this file
- //-------------------------------------------------------------
-
- #include <iostream.h>
- #include "EX09081.H"
-
- void main()
- {
- char choice = '\0';
- int done = 0;
- char response[32]; // Used to store the users response
- long nResponse = 0; // Used to store the users response
- Grade x; // A grade object
-
- do
- {
- cout << endl;
- cout <<
- "Type N or n to find the numeric range of a letter Grade"
- << endl;
- cout <<
- "Type L or l to find the letter grade for a numeric grade"
- << endl;
- cout << "Type Q or q to quit" <<endl;
- cin >> choice;
-
- switch(choice)
- {
- case 'n':
- case 'N':
- cout << "Enter a letter grade: (A B C D or F) ";
- cin >> response;
- cout << response << " "
- << x[(char *)response] << endl;
- break;
-
- case 'l':
- case 'L':
- cout << "Enter a numeric grade: ( 0 - 100 ) ";
- cin >> nResponse;
- if ( ! cin) // test for cin error
- { cin.clear(); // reset cin error state
- cin >> response; // skip offending input
- break;
- }
- cout << nResponse << " "
- << x[nResponse] << endl;
- break;
-
- case 'q':
- case 'Q':
- done = 1;
- break;
- }
- }
- while(!done);
- }
-