Question
Hello, I have a C++ assignment and I am having problems with the following: Phase III: Modify your program so that it also asks each
Hello,
I have a C++ assignment and I am having problems with the following:
Phase III: Modify your program so that it also asks each attendee for a theater concession stand purchase. The attendee must make a selection based on the following choices
1 - Soft Drink (such as Coca Cola, ICCEE, Mineral Water etc...)
2 - Popcorn
3 - Nachos
4 - Soft drink & Popcorn
5 - Soft drink & Nachos
6 - Organic and Gluten-free snacks
7 None
The program output should now also provide a theater concession stand sales summary with a count of each category purchased.
Here is the sample output:
========================== THEATER STATS PROGRAM ========================== Movie theater snacks available for purchase ========================================== 1 - Soft Drink (such as Coca Cola, ICCEE, Mineral Water etc...) 2 - Popcorn 3 - Nachos 4 - Soft drink & Popcorn 5 - Soft drink & Nachos 6 - Organic and Gluten-free snacks 7 - None ========================================== Enter age of attendee (-1 to quit): 34 Movie theater snack purchased. (Select items 1 - 7):4 -------------------------- Enter age of attendee (-1 to quit): 16 Movie theater snack purchased. (Select items 1 - 7):5 -------------------------- Enter age of attendee (-1 to quit): 68 Movie theater snack purchased. (Select items 1 - 7):12 Invalid selection, please choose from 1 - 7 Movie theater snack purchased. (Select items 1 - 7):6 -------------------------- Enter age of attendee (-1 to quit): 53 Movie theater snack purchased. (Select items 1 - 7):6 -------------------------- Enter age of attendee (-1 to quit): 39 Movie theater snack purchased. (Select items 1 - 7):1 -------------------------- Enter age of attendee (-1 to quit): 23 Movie theater snack purchased. (Select items 1 - 7):2 -------------------------- Enter age of attendee (-1 to quit): 21 Movie theater snack purchased. (Select items 1 - 7):3 -------------------------- Enter age of attendee (-1 to quit): 21 Movie theater snack purchased. (Select items 1 - 7):4 -------------------------- Enter age of attendee (-1 to quit): -1 ================================== THEATER STATS PROGRAM RESULTS ================================== age 0 to 18: 1 age 19 to 30: 3 age 31 to 40: 2 age 41 to 60: 1 over 60: 1 The average age was 34 The youngest person in attendance was 16 The oldest person in attendance was 68 Theater Concession Stand sales ================================== Soft Drink (such as Coca Cola, ICCEE, Mineral Water etc.): 1 Popcorn: 1 Nachos: 1 Soft drink & Popcorn: 2 Soft drink & Nachos: 1 Organic and Gluten-free snacks: 2 Process returned 0 (0x0) execution time : 169.589 s Press any key to continue.
Here is my code so far
#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
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; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started