Write a program that able to compute the pay of both types of employees: retired one’s and employed, the retired employees will receive pension and it will be computed and displayed with proper variables and messages. The pension of the employer will be fixed and will be computed on the basis of age, if the age of the retired employer is between 60 to 70 years then its pension will be 30000 and if the age is greater than 70 then the pension will be 40000. The pay of the employer will be computed on daily worked hours and the net pay will be shown with the proper messages of gross salary. The pay of the employer will be 1000 rupees per day if he/she worked for 8 hours and if it works more than 8 hours, then he will be paid 300 rupees per hour but the extra time can only be utilized at maximum of 3 hours.
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
#include<iostream>
using namespace std;
int main()
{
cout<<"\nEnter the employee type to compute the pay for: "<<endl;
cout<<"\n1.Retired one's"<<endl;
cout<<"2.Employed one's"<<endl;
int option;
cout<<"\nEnter your option: ";
cin>>option;
if(option == 1)
{
cout<<"\nEnter the age of the employee: ";
int age;
cin>>age;
if(age>=60 && age <=70)
{
cout<<"\nThe retired employee age is: "<<age<<endl;
cout<<"The pension of the employee is: 30000"<<endl;
}
else if(age>70)
{
cout<<"\nThe retired employee age is: "<<age<<endl;
cout<<"The pension of the employee is: 40000"<<endl;
}
else
{
cout<<"\nThe age you have entered is not valid for a retired employee, it's too low"<<endl;
}
}
else if(option == 2)
{
cout<<"\nEnter the number of hours worked per day: ";
int hours;
cin>>hours;
int pay;
int extra_pay = 0;
if(hours == 8)
{
pay = 1000;
}
else if(hours > 8)
{
if(hours > 11)
{
pay = 1000;
extra_pay = 3 * 300;
}
else{
pay = 1000;
int extra_hours = hours-8;
extra_pay = extra_hours * 300;
}
}
cout<<"\nThe number of hours worked by the employee is: "<<hours<<endl;
int total_pay = pay + extra_pay;
cout<<"The total pay for the employee is: "<<total_pay;
}
else
{
cout<<"\nInvallid option please try again"<<endl;
}
return 0;
}
SAMPLE PROGRAM OUTPUT
Comments
Leave a comment