Question: I am almost finished with this code, but am running into one problem with the counters being off. The counts for males and females are
I am almost finished with this code, but am running into one problem with the counters being off. The counts for males and females are incorrect. I need help with how to edit the code to get these two counters right.
Here is my code:






Here is my code so you can also copy/paste into your compiler to try and help me debug and fix:
// Theater Problem
#include
//Variables using namespace std;
int main() { int age, ageTotal = 0; int ageGroupOne = 0, ageGroupTwo = 0, ageGroupThree = 0, ageGroupFour = 0, ageGroupFive = 0; int sum=0, counter = 0, youngest = 0, oldest = 0; int nMales=0, nFemales=0; char gender, M, F; cout > age; youngest = age; oldest = age; cout > gender; gender = M; gender = F; //Loop to get input of ages and genders of attendees while(age != -1) { //Get age input if (age >= 0) { counter++; sum = sum + age; cout > age; //Terminate before asking for gender if -1 is entered. if (age == -1) break; //Get gender input cout > gender; nMales++; nFemales++; } //Group ages by age range starting with control variable. if (age =0 && age = 19 && age = 31 && age =41 && age =61 && age oldest) oldest = age; } //Outside the loop. Display outputs and calculations. //AGE GROUPS OF ATTENDEES cout
//NUMBER OF FEMALES cout 4 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
