Write 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 | Bonus of 500 pesos
No. of hours > 40 and <=45 | Bonus of 250 pesos
No. of hours > 35 and <=40 | Bonus of 150 pesos
Display the basic salary, bonus and the total salary (basic salary + bonus) for the week.
Solution:
#include <iostream>
using namespace std;
int main()
{
float amount, hours, bonus, total;
cout<<"Enter hours worked: ";
cin>>hours;
cout<<"Enter the hourly rate: ";
cin>>amount;
if (hours >45)
bonus = 500;
else if (hours > 40 && hours <=45)
bonus = 250;
else if (hours >35 && hours <=40)
bonus = 150;
else
bonus = 0;
total= (hours*amount) + bonus;
cout<<"The basic salary is "<< hours*amount<<endl;
cout<<"The bonus is "<<bonus<<endl;
cout<<"The total salary is "<<total<<endl;
return 0;
}
No comments:
Post a Comment