Create a simple programmer prototype library using a for your GrossPay Functon P
ID: 3692823 • Letter: C
Question
Create a simple programmer prototype library using a for your GrossPay Functon Prototypes Write a,cpp We that rcfuoes your functions your Grow Pay program but no prototype Create a program called OverTime that calls gotHoursWorked0, and gotPayRatc0 from your GrossPay.cpp No. Matte sure that or 40 hours or below. cat CalcGross0 from your GrossPay program. For more than 40 hours. werite a new method of mar) in your Overtime program that pay me first 40 hours at straight Pay Rate and anything above 40 hours at 1.6 times Pay Rate. Note - It there were any issues in your old Gross Pay program, make sure they are fixed before using the code 'or this program. The final datertime to submit the assgnrrent is Friday. April 22nd at midnight.Explanation / Answer
//Header file
//GrossPay.h
#ifndef GROSSPAY_H
#define GROSSPAY_H
//function prototypes
int getHoursWorked();
double getPayRate();
#endif GROSSPAY_H
---------------------------------------------------------------------------------------------------
//GrossPay.cpp
//implementation file
#include<iostream>
#include "GrossPay.h"
using namespace std;
//Function getHoursWorked that prompt number of hours worked
int getHoursWorked()
{
int hours;
cout<<"Enter number of hours worked : ";
cin>>hours;
return hours;
}
//Function getPayRate that prompt pay rate
double getPayRate()
{
double payRate;
cout<<"Enter pay rate : ";
cin>>payRate;
return payRate;
}
---------------------------------------------------------------------------------------------------
/**C++ program that calls the function getHoursWorked
and getpayRate and then finds the gross income and print
to console*/
//header file
#include<iostream>
//include GrossPay header file
#include "GrossPay.h"
using namespace std;
double calcGross(int hours,double payrate);
int main()
{
//call getHoursWorked
int hours=getHoursWorked();
//call getPayRate
double payrate=getPayRate();
//call calcGross
double gross=calcGross(hours,payrate);
//print hours,
cout<<"Number of hours : "<<hours<<endl;
cout<<"Pay rate : $"<<payrate<<endl;
cout<<"Gross Income :$ "<<gross<<endl;
system("pause");
return 0;
}
//Function that takes hours and payrate and returns gorss income
double calcGross(int hours,double payrate)
{
double gross=0;
if(hours<40)
gross=hours*payrate;
else
gross=40*payrate+(hours-40)*payrate*1.5;
return gross;
}
---------------------------------------------------------------------------------------------------
Sample output
Enter number of hours worked : 55
Enter pay rate : 15
Number of hours : 55
Pay rate : $15
Gross Income :$ 937.5
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.