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:

I am almost finished with this code, but am running into oneproblem with the counters being off. The counts for males and femalesare incorrect. I need help with how to edit the code toget these two counters right. Here is my code: Here is mycode so you can also copy/paste into your compiler to try andhelp me debug and fix: // Theater Problem #include #include #include //Variables

Here is my code so you can also copy/paste into your compiler to try and help me debug and fix:

// Theater Problem

#include #include #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 5 #include 6 #include 7 8 INariables 9 using namespace std; 10 11 int mainO 12 13 14 15 16 17 18 19 20 21 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 ; 23

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!