In: Computer Science
(C++) Follow the template given to calculate and print the monthly salary of an employee. We assume the employee works for 50 weeks during the year with an hourly rate of $25. Your program should ask the user the workHoursPerWeek. If it's over 40, then the excess hours (i.e., workHoursPerWeek over 40) are paid with 20% overtime rate. Note: just print out the monthly salary.
Example: If I work for 45 hours with a rate of $30/hr, then my weekly pay is 40x30+(45-40)x(1+0.2)x30=1200+180=1380.
using namespace std;
#include<iostream>
int main()
{
int workhrs,pay; //Initialising variable
cout<<"Enter the work hours per week: "; //User enters hours
per week
cin>>workhrs;
int hrrate=30; //Hourly rate of 30$
if(workhrs>40) //If hours>40
pay=40*hrrate+(workhrs-40)*1.2*hrrate; //Pay is calculated
accordingly
else
pay=hrrate*workhrs;
cout<<"\nThe monthly pay is: $ "<<pay;
}