Question

An employee is paid at a rate of $16.78 per hour for regular hours worked in...

An employee is paid at a rate of $16.78 per hour for regular hours worked in a week. Any hours over that are paid at the overtime rate of 1.5 times that. From the worker's gross pay, 6% is withheld for social security tax, 14% is withheld for federal income tax, 5% is withheld for state income tax, and $10 per week is withheld for union dues. If the worker has three or more dependents, then an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays. Write a C++ program that will read in the number of hours worked in a week and the number of dependents as input, and will then output the worker's gross pay, each withholding amount, and the net take-home pay for the week. Your program should allow the calculation to be repeated as often as the user wishes.

Part 1

Like we did for 'Practice 1' in this course note, divide this task into several subtasks. Some of subtasks may be divided into a few sub-subtask.

  • State subtasks/sub-subtasks as comments in C++ code.

Part 2

Write a C++ code to do this task taking steps you define at Part 1.

  • The regular work hours is 40 hours a week.
  • Declare variables to express all constant values used in the code with the modifier const.
    • For example,
    • const double pay_rate_per_hour=16.78;
  • Use appropriate data type for each variable.
  • Amounts in dollar should be formatted; show 2 digits of fraction part to represent the cent, like $456.20.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code for the problem.

I have provided comments for your understanding.

I have created subtasks and sub-subtasks as mentioned.

#include <bits/stdc++.h>

using namespace std;

// declaring constants

const double pay_rate_per_hour = 16.78;

const double overtime_rate = pay_rate_per_hour * 1.5;

const double social_security_tax_percent = 0.06;

const double federal_income_tax_percent = 0.14;

const double state_income_tax_percent = 0.05;

const int union_dues = 10;

const int health_insurance = 35;

const int regular_work_hours = 40;

const int number_of_dependents = 3;

// subtask : calculating pay

double pay_without_deductions(int hours)

{

    if (hours <= regular_work_hours)

    {

        return (hours * pay_rate_per_hour);

    }

    else

    {

        return (regular_work_hours * pay_rate_per_hour + (hours - regular_work_hours) * overtime_rate);

    }

}

// sub-subtask : calculating taxes

double calculate_social_security_tax(double total_pay)

{

    return (total_pay * social_security_tax_percent);

}

// sub-subtask : calculating taxes

double calculate_federal_income_tax(double total_pay)

{

    return (total_pay * federal_income_tax_percent);

}

// sub-subtask : calculating taxes

double calculate_state_income_tax(double total_pay)

{

    return (total_pay * state_income_tax_percent);

}

// subtask : deducting taxes

double deduct_all_deus(double total_pay, int dependents)

{

    // calculating taxes using functions

    double social_security_tax = calculate_social_security_tax(total_pay);

    double federal_income_tax = calculate_federal_income_tax(total_pay);

    double state_income_tax = calculate_state_income_tax(total_pay);

    // subtarcting taxes

    total_pay -= (social_security_tax + federal_income_tax + state_income_tax);

    // subtracting union dues

    total_pay -= union_dues;

    // subtracting health insurance if dependents greater than 3

    if (dependents >= number_of_dependents)

    {

        total_pay -= health_insurance;

    }

    return total_pay;

}

int main()

{

    // calling function any number of times

    while (true)

    {

        // taking inputs

        int hours, dependents;

        cout << "Enter Number of Hours worked this Week:\t";

        cin >> hours;

        cout << "Enter Number of Dependents:\t";

        cin >> dependents;

        // calculating pay

        double gross_pay = pay_without_deductions(hours);

        gross_pay = deduct_all_deus(gross_pay, dependents);

        // printing result

        cout << "Gross Pay:\t" << fixed << setprecision(2) << gross_pay << endl;

        // asking user to continue

        int ans;

        cout << "Do you want to continue(1 = yes, 0 = no):\t";

        cin >> ans;

        if (ans != 1)

        {

            break;

        }

    }

    return 0;

}

Here are the screenshot of the code if the indentation is not clear.

Here is the screenshot of the output.

Hope this helps.

Please rate the answer if you like it.

Do leave a comment.An suggestion/query is much appreciated.

Add a comment
Know the answer?
Add Answer to:
An employee is paid at a rate of $16.78 per hour for regular hours worked in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • An employee is paid at a rate of $16.78 per hour for regular hours worked in...

    An employee is paid at a rate of $16.78 per hour for regular hours worked in a week. Any hours over that are paid at the overtime rate of 1.5 times that. From the worker's gross pay, 6% is withheld for social security tax, 14% is withheld for federal income tax, 5% is withheld for state income tax, and $10 per week is withheld for union dues. If the worker has three or more dependents, then an additional $35 is...

  • 3. Anmol An employee earns $40 per hour and 1.5 times that rate for all hours...

    3. Anmol An employee earns $40 per hour and 1.5 times that rate for all hours in excess of 40 hours per week. Assume that the employee worked 60 hours during the week, and that the gross pay prior to the current week totaled 558,000. Assume further that the social security tax rate was 7.0% (on earnings up to $100,000), the Medicare tax rate was 1.5%, and the federal income tax to be withheld was $614. Required: (1) Determine the...

  • An hourly employee is paid $30/hour for a 40 hour week. Overtime is paid at time-and-a-half...

    An hourly employee is paid $30/hour for a 40 hour week. Overtime is paid at time-and-a-half for hours worked in excess of 40 hours. In the prior week, the employee worked 48 hours. Federal income taxes of $250 were withheld, and state income taxes of $40 were withheld. FICA taxes of 6.2% (Social Security) and 1.45% (Medicare) were also withheld. What is the weekly gross pay amount or this employee? What is the weekly net pay amount for this employee?

  • Calculate Payroll An employee earns $24 per hour and 1.5 times that rate for all hours...

    Calculate Payroll An employee earns $24 per hour and 1.5 times that rate for all hours in excess of 40 hours per week. Assume that the employee worked 60 hours during the week, and that the gross pay prior to the current week totaled $34,800. Assume further that the social security tax rate was 6.0%, the Medicare tax rate was 1.5%, and federal income tax to be withheld was $403. a. Determine the gross pay for the week. $ If...

  • Calculate Payroll An employee earns $36 per hour and 1.75 times that rate for all hours...

    Calculate Payroll An employee earns $36 per hour and 1.75 times that rate for all hours in excess of 40 hours per week. Assume that the employee worked 50 hours during the week, and that the gross pay prior to the current week totaled $52,200. Assume further that the social security tax rate was 6.0%, the Medicare tax rate was 1.5%, and federal income tax to be withheld was $497. a. Determine the gross pay for the week. $ If...

  • Calculate Payroll An employee earns $28 per hour and 1.75 times that rate for all hours...

    Calculate Payroll An employee earns $28 per hour and 1.75 times that rate for all hours in excess of 40 hours per week. Assume that the employee worked 50 hours during the week. Assume that the social security tax rate was 6.0, the Medicare tax rate was 1.5%, and federal income tax to be withheld was $370.30. a. Determine the gross pay for the week. If applicable, round your final answer to two decimal places. b. Determine the net pay...

  • Mike Dooley's regular hourly wage is $16 an hour. He receives overtime pay at the rate...

    Mike Dooley's regular hourly wage is $16 an hour. He receives overtime pay at the rate of time and a half. The FICA tax rate is 7.65%. Mike is paid weekly. For the first pay period in January, Mike worked 49 hours. All hours over 40 earn the overtime rate. Mike's federal income tax withholding is $150 and his state income tax withholding is $60. Mike has authorized that $25 be withheld from his check each pay period for savings...

  • Stephanie Kaur is an employee in Alberta and is paid semi-monthly. Shee worked 82 hours this...

    Stephanie Kaur is an employee in Alberta and is paid semi-monthly. Shee worked 82 hours this pay period at his regular rate of $30.50 per hour. She also had 5 hours of overtime and is paid 4% vacation on each cheque. The employer covers the Group Medical by paying a monthly premium of $54.00per pay and a Life Insurance policy costing $34.00 per month. He receives a yearly car allowance of $1,200. Stepahnie contributes $50.00 per pay to her RRSP...

  • Lenny Florita, an unmarried employee, works 47 hours in the week ended January 12. His pay rate is $12 per hour, a...

    Lenny Florita, an unmarried employee, works 47 hours in the week ended January 12. His pay rate is $12 per hour, and his wages have deductions for FICA Social Security, FICA Medicare, and federal income taxes. He claims four withholding allowances. Compute his regular pay, overtime pay (Lenny earns $18 per hour for each hour over 40 per week), and gross pay. Then compute his FICA tax deduction (6.2% for the Social Security portion and 1.45% for the Medicare portion)....

  • alculate Payroll Consultant Administrator $48 per hour 2 times hourly rate 1 Breakin Away Company has...

    alculate Payroll Consultant Administrator $48 per hour 2 times hourly rate 1 Breakin Away Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Computer Programmer Regular earnings rate $2,210 per week $30 per hour Overtime earnings rate Not applicable 1.5 times hourly rate Number of withholding allowances 3 2 For the current pay period, the computer programmer worked 60 hours and the administrator worked 50 hours. The federal income...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT