All pastes #550440 Raw Edit

Untitled

public text v1 · immutable
·published 2007-06-08 12:46 UTC
rendered paste body
#include <iostream>
using namespace std;

int main( )
{
  int ctr, nWomNoTV, nWomMov, nYoungSport, nOldMSport;
  nWomNoTV = nWomMov = nYoungSport = nOldMSport = 0;

  for(ctr=1;ctr<=3; ctr++)
  {

     int age;
     char gend, inter;

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

     do
     {
       cout<< "What is your gender (M for male, F for female)?\n";
       cin >> gend;

       gend = tolower(gend);
     }
     while((gend !='m')&&(gend !='f'));

     cout << "Which of the following types of TV programs do you watch most often (choose one of N, S, M, E, O or X): \n N:  news \n S:  sport \n M:  movies, soaps, dramas, series  \n E:  educational, documentaries \n O:  other  \n X:  I do not watch TV. \n ";
     cin >> inter;

    inter = tolower(inter);

    if ((gend == 'f') && (inter == 'x'))
        nWomNoTV++;
    else if ((gend == 'f') && (inter == 'm'))
        nWomMov++;
    else if ((age < 20) && (inter == 's'))
        nYoungSport++;
    else if ((gend == 'm') && (age > 35) && (inter == 's'))
        nOldMSport++;
  }

  cout << "women older than 30 years do not watch TV at all : " << nWomNoTV << endl;
  cout << "women indicate M for their favourite : " << nWomMov << endl;
  cout << "people younger than 20 years indicate S for their favourite : " << nYoungSport << endl;
  cout << "men older than 35 years indicate S for their favourite : " << nOldMSport << endl;

}

}