Question: // This program calculates gross pay. #include #include using namespace sdt; // Global constants const double PAY_RATE = 22.55; // Hourly pay rate const double

// This program calculates gross pay. #include #include using namespace sdt;

// Global constants const double PAY_RATE = 22.55; // Hourly pay rate const double BASE_HOURS = 40.0; // Max non-overtime hours const double OT_MULTIPLIER = 1.5; // Overtime multiplier

// Function prototypes double getBasePay(double); double getOvertimePay (double);

int main() { double hours, basePay, overtime = 0.0, totalPay;

// Get the number of hours worked. cout << "How many hours did you work? "; cin >> hours;

// Get the amount of base pay. basePay = getBasePay(hours);

// Get overtime pay, if any. if (hours > BASE_HOURS) overtime = getOvertimePay(hours);

// Set up numeric output formatting. cout << setprecision(2) << fixed << showpoint;

// Display the pay. cout << "Base pay: $" << basePay << endl << "Overtime pay $" << overtime << endl << "Total pay $" << totalPay << endl;

return 0;

}

//*********************************************************** // The getBasePay function accepts the number of * // hours worked as an argument and returns the * // employee's pay for non-overtime hours. * //***********************************************************

double getBasePay(double hoursWorked) { double basePay; // To hold base pay

// Determine base pay. if (hoursWorked > BASE_HOURS) basePay = BASE_HOURS * PAY_RATE; else basePay = hoursWorked * PAY_RATE;

return basePay;

}

//*********************************************************** // The getOvertimePay function accepts the number * // of hours worked as an argument and returns the * // employee's overtime pay. * //***********************************************************

double getOvertimePay(double hoursWorked) { double overtimePay; // to hold overtime pay

// Determine overtime pay. if (hoursWorked > BASE_HOURS) { overtimePay = (hoursWorked - BASE_HOURS) * PAY_RATE * OT_MULTIPLIER;

} else overtimePay = 0.0;

return overtimePay;

}

OUTPUT How many hours did you work? 48 [Enter] Base pay: $902.00 Overtime pay: $270.60 Total pay: $1172.60

QUESTIONS******1) Write a function named calculateTax() 2) Call the function calculateTax() 3) In the function calculateTax(), ask the user to enter the tax rate 4) Use the tax rate entered by the user to calculate tax owed. 5) Display tax owed in the output to the screen in addition to the other output already produced by the program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!