I need this program to display the number of vacation weeks based on the number of years an employee has been with a company. It needs to allow me to enter the number of years for as many employees as I like. I would also like it to calculate and display the total number of employees entered.
How do I make code for a counter? And how do I get the error message to work(b/c it's not working as far as I know)? I would really appreciate any advice or help.
#include <iostream>
using namespace std;
int main()
{
int years = 0;
int counter = 1;
int employees = 0;
cout << "Enter the years employed: ";
cin >> years;
while (years != -3)
{
{if (years == 0)
cout << "Vacation weeks: 0" << endl;
else if (years > 0 && years <= 5)
cout << "Vacation weeks: 1" << endl;
else if (years > 5 && years <= 10)
cout << "Vacation weeks: 2" << endl;
else if (years > 10)
cout << "Vacation weeks: 3" << endl;
else cout << "Invalid years" << endl;
}
cout << "Enter the years employed: ";
cin >> years;
}
return 0;
}
How do I make code for a counter? And how do I get the error message to work(b/c it's not working as far as I know)? I would really appreciate any advice or help.
#include <iostream>
using namespace std;
int main()
{
int years = 0;
int counter = 1;
int employees = 0;
cout << "Enter the years employed: ";
cin >> years;
while (years != -3)
{
{if (years == 0)
cout << "Vacation weeks: 0" << endl;
else if (years > 0 && years <= 5)
cout << "Vacation weeks: 1" << endl;
else if (years > 5 && years <= 10)
cout << "Vacation weeks: 2" << endl;
else if (years > 10)
cout << "Vacation weeks: 3" << endl;
else cout << "Invalid years" << endl;
}
cout << "Enter the years employed: ";
cin >> years;
}
return 0;
}
Comment