Logical error - same output no matter what the input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zelmila19
    New Member
    • Apr 2008
    • 16

    Logical error - same output no matter what the input

    Hi,
    Can someone tell me what's wrong with my code cos when I test the program, it always gives me the fee as 20 for everything..... .

    [code=cpp]
    #include <iostream>

    using std::cout;
    using std::cin;
    using std::endl;

    int main()
    {
    //declare variables
    char memberStatus = ' ';
    int age = 0;
    int fee = 0;

    //enter status
    cout << "Membership status (M for member or N for non-member): ";
    cin >> memberStatus;
    cout << "What is your age: ";
    cin >> age;

    //assign seminar fee
    if (toupper(member Status) == 'M' && age < 65)
    {
    fee = 10;
    }
    else if (toupper(member Status) == 'M' && age >= 65)
    {
    fee = 5;
    }
    else if (toupper(member Status) == 'N');
    {
    fee = 20;
    } //end if


    //display output
    cout << "Fee: " << fee << endl;

    system("PAUSE") ;
    return 0;
    } //end of main function[/code]
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Look at this line toupper(memberS tatus) == 'N' very carefully.

    Comment

    • zelmila19
      New Member
      • Apr 2008
      • 16

      #3
      Originally posted by weaknessforcats
      Look at this line toupper(memberS tatus) == 'N' very carefully.
      Thanks the semi-colon fellow :)

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        zelmila19-

        I made a few modifications to this thread so that it's in line with our Posting Guidelines. If you wouldn't mind perusing them, I'd appreciate it.

        Thanks

        sicarie

        Comment

        Working...