So far I have this but I need to use switch statements to make age< certain numbers for each age group.

``````#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

const float CHILDREN_MALE=50.00;
const float CHILDREN_FEMALE=55.00;
const float TEENAGERS_MALE=150.00;
const float TEENAGERS_FEMALE=155.00;

int main()
{
int Age, name;
float Mcost=0.0;
float total=0.0;
char Gender;
cout << fixed << showpoint << setprecision (2);

cout << "-------------Fullerton Health Club--------------" << endl;
cout << "Children (Age 1-12) " << endl;
cout << setfill ('.');
cout << left << setw(15) << "\tMale" << right << setw(6) << CHILDREN_MALE << endl;
cout << left << setw(15) << "\tFemale" << right << setw(6) << CHILDREN_FEMALE << endl;
cout << "Teenagers (Age 13-19)" << endl;
cout << left << setw(15) << "\tMale" << right << setw(6) << TEENAGERS_MALE << endl;
cout << left << setw(15) << "\tFemale" << right << setw(6) << TEENAGERS_FEMALE << endl;
cout << "Adults (Age > 19)" << endl;
cout << left << setw(15) << "\tMale" << right << setw(6) << ADULTS_MALE << endl;
cout << left << setw(15) << "\tFemale" << right << setw(6) << ADULTS_FEMALE << endl;

//Ask for age, gender, and full name
cout << "Enter your age? ";
cin >> Age;
cout << "Enter your gender(m/f)? ";
cin >> Gender;
cout << "Enter your full name: ";
cin >> name;
cout << "  Hello Mr. " << name << ",";
cout << "

system ("pause");
return 0;
}
``````

Has to have 3 different outputs like this with different ages:

``````Enter your age? 48
Enter your full name: Barack H Obama
Hello Mr. Barack H Obama

Enter your full name: Hilary Clinton
Hello Mrs. Hilary Clinton
``````

It is unlikely that you really want a switch statement. The problem is basically a set of decision based on two different criteria: age/gender. That ends up as a two state switch statement embedded in another two state switch statement... uck!!

What is wrong with

``````float membershipFee;
if (age < 12)
{
if (Gender == 'm')
membershipFee=XXX;
else
membershipFee=YYY;
}
else if (age < 18)
{
if (Gender == 'm')
membershipFee=ZZZ;
else
membershipFee=AAA;
}
else
{
// etc......

}
// ....
std::cout<<"Membership fee = "<<memberShipFee<<std::endl;
``````

Obviously you have to replace XXX, YYY by your actual constants and complete the if else statment.

If you are comfortable with this construct you might like to replace the inner if statement `if (Gender=='m')` part with

``````  membershipFee = (Gender=='m') ? XXX : YYY;
``````

but if that is not familiar to you, don't worry it is just a short hand for the inner if statement and you can ignore that and you the slightly longer form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.