Make a program that asks the user for the hours worked for the week and the hourly rate. The basic salary is computed as:
Salary = hours worked*hourly rate
Bonuses are given:
-No. of hours > 45
~No of hours > 40 and <= 45
✓No of hours > 35 and <= 40
-Bonus of 500 pesos
~Bonus of 250 pesos
✓Bonus of 150 pesos
SOLUTION CODE
#include <iostream>
using namespace std;
int main() {
//e user for the hours worked for the week and the hourly rate.
cout<<"Enter the hours worked for the week: ";
int hours_worked;
cin>>hours_worked;
cout<<"Enter the hourly rate: ";
int hourly_rate;
cin>>hourly_rate;
double salary = hours_worked*hourly_rate;
double bonus;
if(hours_worked>45)
{
cout<<"Hours worked = "<<hours_worked<<endl;
cout<<"Hourly rate = "<<hourly_rate<<endl;
cout<<"Salary = "<<salary+500.0<<" pesos"<<endl;
}
else if(hours_worked >40 && hours_worked <= 45)
{
cout<<"Hours worked = "<<hours_worked<<endl;
cout<<"Hourly rate = "<<hourly_rate<<endl;
cout<<"Salary = "<<salary+250.0<<" pesos"<<endl;
}
else if(hours_worked > 35 && hours_worked <= 40)
{
cout<<"Hours worked = "<<hours_worked<<endl;
cout<<"Hourly rate = "<<hourly_rate<<endl;
cout<<"Salary = "<<salary+150.0<<" pesos"<<endl;
}
else
{
cout<<"Hours worked = "<<hours_worked<<endl;
cout<<"Hourly rate = "<<hourly_rate<<endl;
cout<<"Salary = "<<salary<<" pesos"<<endl;
}
return 0;
}
Comments
Leave a comment