Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Copy and paste the code below into Visual Studio. Initialize the variable overtimePay to be 0 . 0 . Then run the program to see
Copy and paste the code below into Visual Studio. Initialize the variable "overtimePay" to be Then run the program to see how much overtime pay an employee will get if they work hours in one week?
This program calculates gross pay. It uses global constants.
#include
#include
using namespace std;
Global constants
const double PAYRATE ; Hourly pay rate
const double BASEHOURS ; Max nonovertime hours
const double OTMULTIPLIER ; Overtime multiplier
Function prototypes
double getBasePaydouble;
double getOvertimePaydouble;
int main
double hours, Hours worked
basePay, Base pay
overtimePay, Overtime pay
totalPay; Total pay
Get the number of hours worked
cout "How many hours did you work? ;
cin hours;
Get the amount of base pay
basePay getBasePayhours;
Get overtime pay, if any
if hours BASEHOURS
overtimePay getOvertimePayhours;
Calculate the total pay
totalPay basePay overtimePay;
Display the pay
cout setprecision fixed showpoint;
cout "Base pay $ setw basePay endl;
cout "Overtime pay $ setw overtimePay endl;
cout "Total pay $ setw totalPay endl;
return ;
getBasePay
This function uses the hours worked value passed in to
compute and return an employee's pay for nonovertime hours.
double getBasePaydouble hoursWorked
double basePay;
if hoursWorked BASEHOURS
basePay BASEHOURS PAYRATE;
else
basePay hoursWorked PAYRATE;
return basePay;
getOvertimePay
This function uses the hours worked value passed in
to compute and return an employee's overtime pay.
double getOvertimePaydouble hoursWorked
double overtimePay;
if hoursWorked BASEHOURS
overtimePay
hoursWorked BASEHOURS PAYRATE OTMULTIPLIER;
else
overtimePay ;
return overtimePay;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started