begginers if statement problem
Here's my problem. I have just finished reading up on the code tutorials and i have programed this little thing. The only problem is that when i enter the age 30 and the # of children as <=0 it says what its supposed to say at age 20 and # of children as <=0. Some goes with age 30 and # of children as 1 and age 20 and # of children as >=1. Also with the age 30 and # of children as 5 and age 20 and # of children as >=1.
Here is my code.
Code:
#include <iostream>
using namespace std;
int main()
{
int age;
int children;
cout<<"Please enter your age: ";
cin>> age;
cout<<"Please enter the number of children you have: ";
cin>> children;
cin.ignore();
if ( (age < 20 && children <= 0) ) {
cout<<"How cute, you're not even married yet!\n";
}
else if ( age <= 20 && children >= 1 ) {
cout<<"Thats disgusting... really.\n";
}
else if ( age >= 21 && children <= 0 ) {
cout<<"Getting ready to get a little action?\n";
}
else if ( age >= 21 && children >= 1 ) {
cout<<"Not bad. I hope you can still find the time to go to college\n";
}
else if ( age >= 30 && children <= 0 ) {
cout<<"Lonely little feller now aren't we. :(\n";
}
else if ( age >= 30 && children >= 1 ) {
cout<<"You're perfect.\n";
}
else if ( age >= 30 && children >= 5 ) {
cout<<"Busy little feller aren't we!\n";
}
cin.get();
}