Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main()
- {
- int grade;
- int counter = 0;
- int aValue = 0;
- int bValue = 0;
- int cValue = 0;
- int dValue = 0;
- int fValue = 0;
- double total = 0;
- cout << "Enter last semesters grades: " << endl;
- while ( (grade = cin.get() ) != EOF )
- {
- switch (grade)
- {
- case 'A':
- case 'a':
- aValue += 4;
- counter += 1;
- break;
- case 'B':
- case 'b':
- bValue += 3;
- counter += 1;
- break;
- case 'C':
- case 'c':
- cValue += 2;
- counter += 1;
- break;
- case 'D':
- case 'd':
- dValue +=1;
- counter += 1;
- break;
- case 'F':
- case 'f':
- fValue += 0;
- counter += 1;
- break;
- case '\n':
- case ' ':
- break;
- default:
- cout << "Incorrect letter grade" << endl;
- break;
- }
- }
- total = aValue + bValue + cValue + dValue + fValue;
- cout << setprecision(2) << fixed << total/counter << endl;
- system ("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment