Advertisement
JustACodingStudent

Grade Reporter

Apr 29th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. double CalcAverage(double t1, double t2)
  6. {
  7.     double avg;
  8.     avg = (t1 + t2) / 2.0;
  9.     return(avg);
  10. }
  11.  
  12. char GradeConvert(double avg)
  13. {
  14.     char grade;
  15.     if(avg >= 90){
  16.         grade = 'A';
  17.     }
  18.     else if(avg >= 80){
  19.         grade = 'B';
  20.     }
  21.     else if(avg >= 70){
  22.         grade = 'C';
  23.     }
  24.     else if(avg >= 65){
  25.         grade = 'D';
  26.     }
  27.     else{
  28.         grade = 'F';
  29.     }
  30.     return(grade);
  31. }
  32.  
  33. void PrintRecord(string course, string name, double num, char letter)
  34. {
  35.     system("cls");
  36.     cout << "Course: " << course << endl;
  37.     cout << "\n    Student: " << name << endl;
  38.     cout << "    Numeric Average: " << num << endl;
  39.     cout << "    Letter Grade: " << letter << endl;
  40.     cout << "\n";
  41.     system("pause");
  42. }
  43.  
  44. int main()
  45. {
  46.     string c, n;
  47.     double t1, t2, a;
  48.     char l, r;
  49.     do{
  50.         system("cls");
  51.         cout << "Enter course: ";
  52.         getline(cin, c);
  53.         cout << "Enter name: ";
  54.         getline(cin, n);
  55.         cout << "Enter midterm and finals grades:" << endl;
  56.         cin >> t1;
  57.         cin >> t2;
  58.         a = CalcAverage(t1, t2);
  59.         l = GradeConvert(a);
  60.         PrintRecord(c, n, a, l);
  61.         cout << "\nWould you like to enter another course(y/n): ";
  62.         cin >> r;
  63.         cin.ignore();
  64.     }while(r == 'y');
  65.     return(0);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement