char sex; // 'M' == male 'F' == female
int age; // Infant age less than 2
// toddlers age greater than or equal 2 and less than 4
// child age greater than equal to 4 and less than 13
// teen age greater than equal 13 less than 20
// adult age greater than or equal to 20 and less than 55
// senior age greater than or equal 55
Based on the information provided above, write a program that finds female teen and male child.
The output should look like the following:
Please fill out the following information.
Sex: Age:
A female teen or a male child found
or
Neither a female teen nor a male child found
Display either of the two messages based on the result of the input data.
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char sex;
int age;
cout << "Sex (M or F):";
cin >> sex;
cout <<"Age: ";
cin >> age;
if ((sex == M) || (sex == F) && (age <2))
else if ((sex == M) || (sex == F) && (age >=2 && age < 4))
else if ((sex == M) || (sex == F) && (age >= 4 && age < 13))
else if ((sex == M) || (sex == F) && (age >= 13 && age < 20))
else if ((sex == M) || (sex == F) && (age >= 20 && age < 55))
else if ((sex == M) || (sex == F) && (age >= 55))
cout << "\nSex:";
cout << gender;
cout << "\nAge:";
cout << age << endl;
return 0;
}
This is what i got so far following an example from the book. I just want to know if I'm going in the right direction some advice would be helpful as to where to go next from here. I still figuring out how to declared the ages but i need a little help. Thanks