nested IF statements


The program has to compute four totals: using nested If statement.
How many people do not read a newspaper,
how many men older than 40 years read a newspaper or twice a week,
how many woman older than 40 read a newspaper once a week, and
how many men read a newspaper 7 days a week.

#include <iostream>
using namespace std;

int main()
{
int age, numDaysPerWeek, number, i, people;
char gender, m, f;

for (int i = 1; i <= 13; i++)
{
cout << "Person number "<< endl;
cout << i << endl;
cout << endl;


cout << " How old are you? " << endl;
cin >> age;
cout << age <<" years old "<< endl<<endl;

do
{
cout << "What is your gender ? Enter M(for Male)or F(for female) "<< endl;
cin >> gender;
if (gender != 'M' && gender != 'F')
cout << "Type M or F "<< endl;
}while (gender != 'M' && gender != 'F');
cout <<"The gender is ("<< gender <<")"<< endl<<endl;
do
{
cout <<"How many days per week do you read a newspaper? " << endl;
cout <<"Answer 0, 1, 3, 4, 5, 6, or 7 " << endl;
cin >> numDaysPerWeek;
if (numDaysPerWeek >= 0 && numDaysPerWeek >= 8)
cout <<"Enter 0, 1, 2, 3, 4, 5, or 7 "<< endl;
}while (numDaysPerWeek >= 0 && numDaysPerWeek >= 8);
cout <<numDaysPerWeek<<" Times Per week "<< endl<< endl;
}

return 0;
}
Last edited on
What do you have so far?
Topic archived. No new replies allowed.