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