Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C++ REWRITE THIS so that it uses a function to get the payrate, hours, to calculate gross pay, and to calculate the three taxes.

in C++

REWRITE THIS so that it uses a function to get the payrate, hours, to calculate gross pay, and to calculate the three taxes. For the taxes, define one function that is called three different times with different arguments.

// Used for input & Output stream #include

// Used to set decimal place formatting #include using namespace std;

// Main Function int main() {

// Constant variable used to store Union Dues const float UNION_DUES = 10.00;

// Constant variable used to store FICA rate const float FICA_RATE = 0.06;

// Constant variable used to store overtime rate const float OVERTIME_RATE = 1.5;

// Constant variable used to store federal rate const float FEDERAL_RATE = 0.15;

// Constant variable used to store state rate const float STATE_RATE = 0.05;

// Variable to store hourly rate float rate = 0.0;

// Variable to store hours int hours = 0;

// Variable to store gross pay float gross;

// Variable used to store fica tax float fica;

// Variable used to store federal tax float federal;

// Variable used to store state tax float state;

// Variable used to store net pay float netPay;

// Variable used to store net hourly pay float netHourly;

// Set decimal formatting cout << fixed << setprecision(2);

// Print Name cout << JOHNNYl ";

// Loop till valid rate enter do { // Take hourly rate cout << "Enter a value between $10 and $15.00 for hourly rate: "; cin >> rate;

} while (rate < 10.00 || rate > 15.00);

cout << " ";

// Loop till valid hour enter while (hours < 1 || hours > 50) { // Take hours cout << "Enter a value between 1 and 50 for the hours worked: "; cin >> hours; }

cout << " ";

// If hours is greater than 40 if (hours > 40) // Compute gross pay gross = (40 * rate) + (hours - 40) * rate * OVERTIME_RATE;

// If hours is less than equal to 40 else // Compute gross pay gross = hours * rate;

// Compute fica rate fica = gross * FICA_RATE;

// Compute federal rate federal = gross * FEDERAL_RATE;

// Compute state rate state = gross * STATE_RATE;

// Compute net pay netPay = gross - (fica + federal + state + UNION_DUES);

// Compute net hourly pay netHourly = netPay / hours;

// Print results cout << "Hourly Rate: " << rate << " "; cout << "Hours Worked: " << hours << " "; cout << "Gross Pay: " << gross << " "; cout << "FICA Tax: " << fica << " at " << FICA_RATE << " "; cout << "Federal Tax: " << federal << " at " << FEDERAL_RATE << " "; cout << "State Tax: " << state << " at " << STATE_RATE << " "; cout << "Union Dues: " << UNION_DUES << " "; cout << "Net Pay: " << netPay << " "; cout << "Net Hourly: " << netHourly << " ";

cout << "Thank you!" << " ";

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions