#include <iostream> #include <string> using namespace std; int main() { float grade; cout.precision(2); cout << "GPA Conversion" << endl; cout << "--------------" << endl; cout << "Enter your grade: "; cin >> grade; cout << endl; if ( grade <=100 && grade >=96) cout << "You will receive a letter grade of A with a 4.00 GPA."; if ( grade <=95 && grade >=90) cout << "You will receive a letter grade of A- with a 3.70 GPA."; if ( grade <=89 && grade >=87) cout << "You will receive a letter grade of B+ with a 3.30 GPA."; if ( grade <=86 && grade >=84) cout << "You will receive a letter grade of B with a 3.00 GPA."; if ( grade <=83 && grade >=80) cout << "You will receive a letter grade of B- with a 2.70 GPA."; if ( grade <=79 && grade >=77) cout << "You will receive a letter grade of C+ with a 2.30 GPA."; if ( grade <=76 && grade >=74) cout << "You will receive a letter grade of C with a 2.00 GPA."; if ( grade <=73 && grade >=70) cout << "You will receive a letter grade of C- with a 1.70 GPA."; if ( grade <=69 && grade >=67) cout << "You will receive a letter grade of D+ with a 1.30 GPA."; if ( grade <=66 && grade >=64) cout << "You will receive a letter grade of D with a 1.00 GPA."; if ( grade <=63 && grade >=60) cout << "You will receive a letter grade of D- with a 0.70 GPA."; if ( grade <=59 && grade >=0) cout << "You will receive a letter grade of F with a 0.00 GPA."; return 0; }
if
else
int grade; // looking at you code, grade should be an integer. //... if (grade > 100) {// error, input out of range, too high } else if (grade >= 96) {// this handles 96 <= grade <= 100 cout << "You will receive a letter grade of A with a 4.00 GPA."; } else if (grade >= 90) {// this handles 90 <= grade <= 95 //.. } //.. else if ( grade >= 0) { // this handles 0 <= grade <= 59 } else { // error, input out of range, too low }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)