Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In most companies the amount of vacation you receive depends on the number of ye

ID: 3538010 • Letter: I

Question

In most companies the amount of vacation you receive depends on the number of years you've been with the company. Create a C++ program that will allow the user to enter the number of years and you output the weeks of vacation according to the following:

0 years, 0 weeks vacation

1-5 years, 1 weeks vacation

6-10 years, 2 weeks vacation

11+ years, 3 weeks vacation

Prompt the user if they would like to enter another employee. Also Personalize your Program by naming your company!

Add Exception Handling.

I am having trouble with the Exception Handling:

Here is what I came up with!

#include

using

namespace std;

int main()

{

int vacation, years;

char choice ='y';

cout<<

"Welcome to the Vacation schedule for " John Company" ";

while(choice=='y'||choice=='Y')

{

cout<<

"Enter years worked:";

cin>>years;

if(years==0)

vacation=0;

else if(years<=5)

vacation=1;

else if(years<=10)

vacation=2;

else

vacation=3;

cout<<

"years:"<<years<<",vacation weeks:"<<vacation<<endl;

cout<<

"Do you have more employees (y to continue)?";

cin>>choice;

}

return 0;

}

%u3000

%u3000

%u3000

%u3000

%u3000

%u3000

Explanation / Answer

#include<iostream>


using namespace std;


int main()


{


int vacation, years;


char choice ='y';


cout<<


"Welcome to the Vacation schedule for " John Company" ";


while(choice=='y'||choice=='Y')


{

try{

cout<<


"Enter years worked:";


cin>>years;

if(years<0)

throw -1;



if(years==0)


vacation=0;


else if(years<=5)


vacation=1;


else if(years<=10)


vacation=2;


else


vacation=3;


cout<<


"years:"<<years<<",vacation weeks:"<<vacation<<endl;

}

catch(int e)

{

cout<<"Invalid value of year";

}

cout<<


" Do you have more employees (y to continue)?";


cin>>choice;


}


return 0;


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote