Rewrite your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
float hours,rate;
float overtimePay;
float grossPay;
printf("Enter Hours: ");
scanf("%f",&hours);
printf("Enter Rate: ");
scanf("%f",&rate);
//Gross Pay = (Hours > 40? 40 X Rate + Overtime pay: Hours x Rate)
overtimePay = (hours - 40) * rate * 1.5;
grossPay = (hours > 40 ? 40 * rate + overtimePay : hours * rate);
printf("\nGross pay: %.2f\n\n", grossPay);
scanf("%f",&rate);
return 0;
}
Comments
Leave a comment