473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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......

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. int main()
  8. {    
  9.      //declare variables
  10.     char memberStatus  = ' ';
  11.     int age            = 0;
  12.     int fee            = 0;
  13.  
  14.     //enter status
  15.     cout << "Membership status (M for member or N for non-member): ";
  16.     cin >> memberStatus;
  17.     cout << "What is your age: ";
  18.     cin >> age;
  19.  
  20.     //assign seminar fee
  21.     if (toupper(memberStatus) == 'M' && age < 65)
  22.     {
  23.         fee = 10;
  24.     }
  25.     else if (toupper(memberStatus) == 'M' && age >= 65)
  26.     {
  27.         fee = 5;
  28.     }
  29.     else if (toupper(memberStatus) == 'N');
  30.     {
  31.         fee = 20;
  32.     }    //end if
  33.  
  34.  
  35.     //display output
  36.     cout << "Fee: " << fee << endl;
  37.  
  38.     system("PAUSE");
  39.     return 0;
  40. }   //end of main function
Apr 9 '08 #1
3 1543
weaknessforcats
9,208 Expert Mod 8TB
Look at this line toupper(memberStatus) == 'N' very carefully.
Apr 9 '08 #2
Look at this line toupper(memberStatus) == 'N' very carefully.
Thanks the semi-colon fellow :)
Apr 9 '08 #3
sicarie
4,677 Expert Mod 4TB
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
Apr 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TERMAN, IRA, ALABS | last post by:
Hello, I am trying to install Python-2.3. I get the following error when I run ./configure --with-csx=gcc on my Solaris machine. config.status: error: cannot find input file:...
4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
1
by: Frank Jones | last post by:
When manually running resgen.exe from the command prompt (Visual Studio .NET 2003 command prompt) I get the following error: error: Invalid ResX input. error: Specific exception:...
3
by: Denny Schierz | last post by:
hi, i have a logical error in my css file, but i don't no where. have a look: http://lippelt-back.com/fileadmin/template/css/new-body.css i comment this lines:
4
by: GRoll21 | last post by:
The problem starts during my while loop. It checks to see if they hit x or X. If they did, then that means the user wants to exit. Then should go on and hit the return statement. It just quits....
3
by: Lukas | last post by:
title: xml to xml mapping: empty elements output although input element is not empty Why is is that when mapping from a XML schema to another XML schema, when drawing a default connection...
1
by: Sister Ray | last post by:
Hello, I'm trying to debug and compile a application that was developed by a collegue of mine, How ever when i try to build the application I always receive the following error: Compiling...
2
by: gnanapoongothai | last post by:
what is logical error found in the code below .Could any find. If( (x!=3) || (x!=4) ) printf("something"); else printf("something") thanks in advance for your answers.
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
3
by: anchitgood | last post by:
I have tried a lot but unable to correct just 1 logical error in the following code. This error is in the for loop, when fine and minutes are printed as the garbage values. Please check it out: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.