### Terminate a "For" counter loop

At the bottom of the following code, I created a "For" loop where you input the number of employees. I can get the code to compile and run, and you are able to input the data, but if you put in , say 2 employees, it will let you enter the two, but continues beyond that. How do I terminate the loop?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115`` `````` #include #include #include using namespace std; class payroll{ public: void setVariables(int empID, string fName, string lName, int stat, double rate, double hrs){ int employeeID; string firstName; string lastName; int payStat; double hourlyRate,salary,hours; void readdata(); void printreport(); void printdata(); employeeID = empID; firstName = fName; lastName = lName; payStat = stat; if (payStat == 1){ hourlyRate = rate; } else { salary = rate;} hours = hrs; } //declare function to calculate gross pay public: virtual double calculateGrossPay() = 0; double taxRate,taxAmount,grossPay,netPay; double calculateTaxAmount(){ taxRate = .30; //set a flat taxrate 30% taxAmount = grossPay * taxRate; //formula to calculate tax amount return taxAmount; } //end calculateTaxAmount() function double calculateNetPay(){ return netPay; } //end void printheadings(); void printData(){ //print out the data }//end printData() function }; //end Payroll class class employeeSalary : public payroll{ public: double calculateGrossPay() { double regPay,hourlyRate,rate,hours,otHours,otPay; regPay=grossPay; hourlyRate=rate; if (hours > 40) {otHours = (hours - 40); //calculate OT hours otPay = (otHours * hourlyRate); //calculate OT pay grossPay = (regPay + otPay); } else if (hours <= 40) {otHours = 0; otPay = 0; grossPay = regPay;} return grossPay; } }; //end EmployeeSalary class class employeeHourly : public payroll{ public: double calculateGrossPay(){ double regPay,hourlyRate,otHours,hours,otPay; regPay = (40 * hourlyRate); //calculate regular hours if (hours > 40){ otHours = (hours - 40); //calculate OT hours otPay = (otHours * hourlyRate * 1.5); //calculate OT pay grossPay = (regPay + otPay); //calculate gross pay } //enf if clause for gross pay with overtime else { otHours = 0; otPay = 0; grossPay = regPay; } //end else clause for four hours return grossPay; } //end calculateGrossPay() function }; //end EmployeeHourly class void printHeader(){ }//end printHeader() function int main(void){ int EmployeeCount,TotalEmployeeCount,EmployeeCounter,stat,empID,TotalEmployeeCounter; double hrs,rate,Grosspay,TaxAmount,NetPay; string fName,lName; EmployeeCounter=0; cout<<"Enter # of employees you want to process: "; cin>>TotalEmployeeCount; payroll *employee[100]; //while loop to get input for each employee cerr<<"EmployeeCounter= "<>stat; if (stat == 1){cout<<"Instantiating an HOURLY employee object inherited from base class payroll..."<>empID; cout<<"Enter employee's first name: ";cin>>fName; cout<<"Enter employee's last name: ";cin>>lName; cout<<"Enter employee's hourly wage: "; cin>>rate; cout<<"Enter employee's hours for this week: "; cin>>hrs; employee[EmployeeCounter] = new employeeHourly(); employee[EmployeeCounter]->setVariables(empID, fName, lName, stat, rate, hrs); employee[EmployeeCounter]->calculateGrossPay(); employee[EmployeeCounter]->calculateTaxAmount(); employee[EmployeeCounter]->calculateNetPay(); } //end if else{ cout<<"Instantiating a SALARY employee object inherited from base class payroll..."<>empID; cout<<"Enter employee's first name: ";cin>>fName; cout<<"Enter employee's last name: ";cin>>lName; cout<<"Enter employee's hourly wage: "; cin>>rate; cout<<"Enter employee's hours for this week: "; cin>>hrs; employee[EmployeeCounter]=new employeeSalary(); employee[EmployeeCounter]->setVariables(empID,fName,lName,stat,rate,hrs); employee[EmployeeCounter]->calculateGrossPay(); employee[EmployeeCounter]->calculateTaxAmount(); employee[EmployeeCounter]->calculateNetPay(); } cin.get(); system("pause"); } } }//end while ``````
!indentation