Name this program pay. c - This program reads two values, an hourly wage (double
ID: 3883320 • Letter: N
Question
Name this program pay. c - This program reads two values, an hourly wage (double) and the number of hours worked (integer). Calculate the total weekly pay based on the following guide 0 to 40 hours, use the regular hourly rate 41 to 60 hours, use regular rate for the first 40 hours and 1.5 times the hourly rate for all hours over 40 61 or more hours, use the regular rate for the first 40 hours, 1.5 times the hourly rate for the next 20 hours, and 2.0 times the hourly rate for all hours over 60 For example, entering 12.50 and 45 gives a weekly pay of $593.75 ($500 regular + $93.75 time-and-a-half)Explanation / Answer
Here is your c pay program:
C Pay Program:
#include<stdio.h>
#include<conio.h>
using namespace std;
void main()
{
double HWage,pay=0;
int HWorked;
printf("Enter hourly wage ");
scanf("%lf",&HWage);
printf(" Enter Total hour worked ");
scanf("%d",&HWorked);
if(HWorked<=40)//for 0 to 40 hours
{
pay=HWorked*HWage;
}
else if(HWorked>=41&&HWorked<=60)//for 41 to 60 hours
{
pay=(HWage*40)+((HWorked-40)*1.5*HWage);
}
else//for 61 to more hours
{
pay=(HWage*40)+(20*1.5*HWage)+((HWorked-60)*2.0*HWage);
}
printf(" Weekly pay: %lf",pay);
getch();
}
I hope this solves your problem
Comment if you have any problem in above code
And please give it a thumbs up if it solved your problem :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.