Advertisement
janac

Determine class grade using formula

Dec 1st, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // Determine final class grade using formula:
  6. // Average the two tests and multiply by .4
  7. // Multiply the midterm and final by .3  
  8. // Add these together for the final grade.
  9.  
  10. int main()
  11. {
  12.     float final_grade = 0;
  13.     float test_1 = 0;
  14.     float test_2 = 0;
  15.     float midterm_exam = 0;
  16.     float final_exam = 0;
  17.  
  18.     cout << "Enter grade for test 1: ";
  19.     cin >> test_1;
  20.     cout << "Enter grade for test 2: ";
  21.     cin >> test_2;
  22.     cout << "Enter grade for midterm exam: ";
  23.     cin >> midterm_exam;
  24.     cout << "Enter grade for final exam: ";
  25.     cin >> final_exam;
  26.  
  27.     final_grade = (((test_1 + test_2) / 2) * 0.4) +
  28.         (midterm_exam * 0.3) + (final_exam * 0.3);
  29.  
  30.     cout << "Your final grade is " << final_grade << '\n';
  31.  
  32.     return 0; // End the program.
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement