[ create a new paste ] login | about

Link: http://codepad.org/lnAXhm0E    [ raw code | output | fork | 1 comment ]

pjvangemmeren - C++, pasted on May 15:
#include <iostream>
using namespace std;

int main()
{
    int testScore = 1000;
    char grade;

    cout << "Enter your numeric test score and I will\n";
    cout << "tell you the letter grade you earned: ";
    cin >> testScore;

    if (testScore < 60)
        grade = 'F';
    else if (testScore < 70)
        grade = 'D';
    else if (testScore < 80)
        grade = 'C';
    else if (testScore < 90)
        grade = 'B';
    else if (testScore <= 100)
        grade = 'A';
    else if (testScore > 100)
        grade = '?';

    cout << "Your grade is " << grade << ".\n";
    return 0;
}


Output:
1
2
Enter your numeric test score and I will
tell you the letter grade you earned: Your grade is ?.


Create a new paste based on this one


Comments:
posted by pjvangemmeren on May 22
102
reply