Help Please toloswer and to upper question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Esmeralda53
    New Member
    • Oct 2008
    • 1

    #1

    Help Please toloswer and to upper question

    I did a simple program Passing garde and I have to be able to enter grades in lower or upper case but for some reason my code does not accepts the lowercase grades can someone help me please here is part of my code....

    #include <cctype>
    #include <iostream>
    using namespace std;

    // required for conversion to lowercase
    class toLower {public: char operator()(char c) const {return tolower(c);}};
    char getGrade()

    {

    char grade = 'Q'; // the default value
    grade = tolower(grade);
    while (true)

    {
    cout << "What is your grade? [A, B, C, D, F, or Q to quit]: ";
    cin >> grade;
    cin.ignore(1000 , 10);
    if (grade == 'A' || grade == 'B' || grade == 'C') break;
    if (grade == 'D' || grade == 'F') break;
    if (grade == 'Q' || grade == 'q') break;

    cout << grade << " is not a valid grade. Try again..." << endl;

    } // while
    return grade;
    } // getGrade
    int main()
    {
    char grade;
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    Follow the execution of your code through an iteration and see where the case is actually changed. (Hint: It's not where it should be.)

    Comment

    Working...