use at least two functions in your program. //Functionthat will calculate return
ID: 673610 • Letter: U
Question
use at least two functions in your program. //Functionthat will calculate returns gross pay double calculateGrossPay(double hoursWork, double ratePerHour); // Function that will calculate and returns net pay double calculateNetPay(double grossPay, int taxRate); ]Use loop to allow users to enter multiple employees. Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate. For example if the user’s hourly rate is $15 and worked for 48 hours, the additional 8 hours will be paid at $22.50/hour. Use 5% as tax deduction. The program will calculate and display the net payment. The following is a sample of the program output: Enter your first and last name: Jane Doe ID number: E1007 Hours worked: 48.0 Hourly rate: 15.0 Name: Jane Doe ID# E1007 Hours worked: 48.00 Regular weekly hours: $600.00 Additional 8 hours worked: $180.00 Gross Pay: $780.00 5% Tax: $39.00 Net Pay: $741.00
Explanation / Answer
#include<stdio.h>
#include<conio.h>
double calculategrosspay(double hoursworks,double rateperhour);
double calculatenetpay(double grosspay,double taxrate);
void main()
{
char fnm[10],idn[10]; // fnm used for full name and idn used for id number
double ah,regh,hoursworks,ahw; // hw used for Hourly Workes and ahw used for Additional work houred
int i,n;
double gs,netpay,grosspay,rateperhour,taxrate;
clrscr();
printf("Enter First Name and LAst Name:");
fflush(stdin);
scanf("%s",fnm);
printf("Enter Id Number:");
fflush(stdin);
scanf("%s",idn);
printf("Hours Worked:");
scanf("%lf",&hoursworks);
printf("Rate per Hour:");
scanf("%lf",&rateperhour);
printf("Additional Hour:");
scanf("%lf",&ah);
printf(" Full Name:%s",fnm);
printf(" ID Number:%s",idn);
regh=hoursworks+ah;
printf(" Regular Weekly Hours:%.2f",regh);
printf(" Additional %.2lf Hours worked",ah);
printf(" Gross pay:%lf",calculategrosspay(hoursworks,rateperhour));
gs=calculategrosspay(hoursworks,rateperhour);
printf(" 5% Tax: %f",(gs*taxrate)/100);
printf(" Net Pay:%.2lf",calculatenetpay(grosspay,taxrate));
getch();
}
double calculategrosspay(double hoursworks,double rateperhour)
{
double grosspay;
if(hoursworks<=40)
{
grosspay=hoursworks*rateperhour;
}
else
{
grosspay=(hoursworks-40)*22.50;
}
return grosspay;
}
double calculatenetpay(double grosspay,double taxrate)
{
double netpay,tx;
tx=(grosspay*taxrate)/100;
netpay=grosspay-tx;
return netpay;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.