Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finished code- //This program is used to keep track of theatre attendees age and sex. #include #include #include #include using namespace std; int main() {

Finished code-

//This program is used to keep track of theatre attendees age and sex.

#include #include #include #include

using namespace std;

int main() { int age=0; int totalage=0; int group1=0, group2=0, group3=0, group4=0, group5=0; int total=0; int youngest=500; int oldest=0; int male=0; int female=0; char gender;

while(age>=0) { cout <<("Enter age of attendee(-1 to quit): "); cin >>age; totalage=totalage+age; if(age>0) { cout <<"Enter gender (M or F): "; cin >>gender; if(gender == 'm' || gender== 'M') { male++; gender='0'; } if(gender == 'f' || gender== 'F') { female++; gender='0'; } } if(youngest>age && age>0) { youngest=age; } if(oldest=0) { oldest=age; }

if(age>=0 && age<=18) { group1++; age=0; total++; } else if(age>19 && age<=30) { group2++; age=0; total++; } else if(age>30 && age<=40) { group3++; age=0; total++; } else if(age>40 && age<=60) { group4++; age=0; total++; } else if(age>60) { group5++; age=0; total++; } } if(age == -1) { cout <<" age 0-19: " <

return 0; }

}

Resubmitting this because I failed to specify that this is for c++. Thanks for any assistance!

This program is broken down into phases for your convenience only. Please turn in only the final phase. Before turning in your program, please make sure that it does something reasonable if the user enters a negative number the first time.

Phase I: Write a program for a theater that will keep track of how many people in each of 5 age categories attended a particular movie. Use the 5 age categories listed below in the sample screen output. The user will enter a number of ages, entering a negative number when there are no more ages to enter. Your program will then report on how many people in each age group attended. Sample screen output:

 Enter age of attendee (-1 to quit): 34 Enter age of attendee (-1 to quit): 16 Enter age of attendee (-1 to quit): 68 Enter age of attendee (-1 to quit): 53 Enter age of attendee (-1 to quit): 39 Enter age of attendee (-1 to quit): 23 Enter age of attendee (-1 to quit): 21 Enter age of attendee (-1 to quit): -1 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 

Phase II: Modify your program so that, in addition to the report that the program currently produces, it also gives the average age of the people in attendance, the age of the oldest person in attendance, and the age of the youngest person in attendance. Sample screen output:

 Enter age of attendee (-1 to quit): 34 Enter age of attendee (-1 to quit): 16 Enter age of attendee (-1 to quit): 68 Enter age of attendee (-1 to quit): 53 Enter age of attendee (-1 to quit): 39 Enter age of attendee (-1 to quit): 23 Enter age of attendee (-1 to quit): 21 Enter age of attendee (-1 to quit): -1 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 The average age was 36. The youngest person in attendance was 16. The oldest person in attendance was 68. 

Phase III: Modify your program so that it also asks for the gender of each attendee. Your program should then break the attendance down by gender as well as by age. Sample screen output:

 Enter age of attendee (-1 to quit): 34 Enter gender (M or F): M Enter age of attendee (-1 to quit): 16 Enter gender (M or F): M Enter age of attendee (-1 to quit): 68 Enter gender (M or F): F Enter age of attendee (-1 to quit): 53 Enter gender (M or F): F Enter age of attendee (-1 to quit): 39 Enter gender (M or F): F Enter age of attendee (-1 to quit): 23 Enter gender (M or F): F Enter age of attendee (-1 to quit): 21 Enter gender (M or F): F Enter age of attendee (-1 to quit): -1 age 0 to 18: 1 age 19 to 30: 2 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 males: 2 females: 5 The average age was 36. The youngest person in attendance was 16. The oldest person in attendance was 68. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

LO5 Illustrate the steps in developing a base pay system.

Answered: 1 week ago