Most of you know I'm pretty new at C++, so bear with me please. I have this assignment that I am to write the code for. An employer wants to be able to enter in number of years employed and show weeks of vacation allowed. 0 years, 0 weeks. Years 1-5, 1 week. Years 6-10, 2 weeks. Years 11 and over get 3 weeks. I'm OK until I get to the 11 and over part. I have tried all I know and nothing works.
I'm not asking for the answer, just a hint or two. I like to work out the problem so I can learn, but this is over my head.
//Ch6AppE05.cpp
//Displays the number of vacation weeks due an employee
//Created/revised by Paul Lawry on 10/20/2009
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
int main()
{ //declare constants
int yearsWithTheCompany = 0;
int weeksOfVacation = 0;
//enter input data
cout << "Years with the company: ";
cin >> yearsWithTheCompany;
//assign vacation time
switch (yearsWithTheCompany)
{
case 0:
weeksOfVacation = 0;
break;
case 1:
case 2:
case 3:
case 4:
case 5:
weeksOfVacation = 1;
break;
case 6:
case 7:
case 8:
case 9:
case 10:
weeksOfVacation = 2;
break;
default:
cout << "Invalid years" << endl;
} //end switch
//display weeks of vacation
cout << "Weeks of vacation: " << weeksOfVacation << endl;
return 0;
} //end of main function
Paul
