I"m not 100% sure what you are trying to do but you need a DO WHILE loop instead of a while loop ...
this lets you enters as many as you want, increments number of employees and displays the total number after each input
CODE
#include <iostream>
using namespace std;
int main()
{
//declare variables
int years = 0;
int numberofemployees = 0; //counter
do
{
//enter input data
cout << "Enter the years employed (negative value terminate program): ";
cin >> years;
//if user wants to quit and enters negative number
if(years < 0)
{
cout << "Ending Program"; //display termination
break;
}
numberofemployees++; //increment number of employees
//display vacation weeks
if (years == 0)
{
cout << "Vacation weeks: 0" << endl;
}
else if (years <= 5)
{
cout << "Vacation weeks: 1" << endl;
}
else if (years <= 10)
{
cout << "Vacation weeks: 2" << endl;
}
else
{
cout << "Vacation weeks: 3" << endl;
}
//display current total number of employees
cout << "Total Number Of Employees: " << numberofemployees << endl;
}while (numberofemployees >= 0);
return 0;
} //end of main function
This post has been edited by Topher84: 4 Dec, 2007 - 02:11 AM