Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***C++ Code*** What this Assignment Is About: Learn to use various loops, such as while, do..while and for loop Learn to read & write from/to

***C++ Code***

What this Assignment Is About:

Learn to use various loops, such as while, do..while and for loop

Learn to read & write from/to a text file

Coding Guidelines for All Labs/Assignments (You will be graded on this)

Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc).

Keep identifiers to a reasonably short length.

Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects).

Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent.

Use white space to make your program more readable.

Use comments properly before or after the ending brace of classes, methods, and blocks to identify to which block it belongs.

1. Assignment Description

All employees at FreeMedicalOrgans.com are paid biweekly, i.e., every two weeks. An hourly employee's biweekly gross pay (denoted by variable grossPay) is calculated as the number of hours he or she worked (denoted by variable hrsWorked) during the pay period multiplied by his or her hourly pay rate (denoted by variable payRate). In addition, hourly workers are eligible for overtime pay if their hours worked exceeds 80 hours during the two week pay period. The overtime pay rate is one-and-a-half times the usual pay rate. For example, if Wilma worked 87 hrs and her pay rate is $19.25 per hour, then her gross pay would be calculated as:

grossPay = (80 * $19.25) + (7 * $19.25 * 1.5) = $1742.13

All employees have taxes withheld from their paychecks. Taxes that are withheld by the employer are:

Federal income tax (denoted by variable taxFed)

State income tax (denoted by variable taxState)

Federal social security tax (denoted by variable taxSS)

Federal medicare tax (denoted by variable taxMedicare)

The amounts withheld for this group of four taxes are based on a percentage of the employee's federal taxable gross pay (denoted by variable fedTaxGrossPay). An employee's federal taxable gross pay is equal to his or her gross pay minus deductions made for the mandatory company 401K retirement plan (denoted by variable four01kDeduct) and medical insurance (denoted by variable medInsDeduct).

All employees are required to contribute 6.0% (denoted by constant FOUR01K_RATE = 0.06) of their gross pay to the company 401K retirement plan.

The rate an employee pays for medical insurance is based on the following table (where variable medInsStatus contains the medical insurance status code of 0, 1, or 2

Medical Insurance Status Biweekly

Cost to Employee

Employee only, no dependents (code = 0)

$32.16

Employee + 1 dependent (code = 1)

$64.97

Family (code = 2)

$110.13

The federal income tax withheld (variable taxFed) from the employee's paycheck is based his or her federal taxable gross pay and this table,

Federal Taxable Gross Pay

Federal Tax Withholding Percentage

< $384.62

0.00%

$384.62 and < $1413.67

7.97%

$1413.67 and < $2695.43

12.75%

$2695.43

19.5%

The amount withheld for state income tax (variable taxState) is based on a percentage of federal taxable gross pay per the following table

Federal Taxable Gross Pay

State Tax Withholding Percentage

< $961.54

1.19%

$961.54 and < $2145.66

3.44%

$2145.66

7.74%

Moreover,

The amount withheld for Social Security (variable taxSS) is 6.2% (denoted by constant SS_RATE = 0.062) of federal taxable gross pay

The amout withhold for federal medicare is 1.45% (denoted by constant MEDICARE_RATE = 0.0145) of the employee's federal taxable gross pay.

2. What do you need to compute?

In this program, first you will need to open a text file which contains employee's payroll information of FreeMedicalOrgans.com. The format of each line of the data in the file is:

lastName firstName payRate hrsWorked medInsStatus

All above information are seperated by a tab (\t) and the medInsStatus field is either 0 (for employee only, no dependents), 1 (for employee + one dependent), or 2 (for family); see the Medical Insurance Status Table above. An example hourly employee record would be:

Smith John 15.25 84.0 2

Here, the employee's first and last names are "John" and "Smith". John's pay rate is $15.25 per hour and he worked 84 hours in the last biweekly pay period (4 hours of overtime). John's medical insurance status is 2 (for employee + family). The program shall read the information from the file and perform calculations to determine the following:

Biweekly gross pay (stored in a variable named grossPay)

Company-required 401K deduction (four01kDeduct)

Medical insurance deduction (medInsDeduct)

Federal taxable gross pay (fedTaxGrossPay)

Federal income tax (taxFed)

SS tax (taxSS)

Medicare tax (taxMedicare)

State income tax (taxState)

Total taxes (taxTotal)

Net pay (netPay)

The fedTaxGrossPay is the employees gross pay reduced by his or her medical insurance deduction and mandatory 401K contribution, i.e

fedTaxGrossPay = grossPay - medInsDeduct - four01kDeduct;

The total taxes (taxTotal) is the sum of taxFed, taxSS, taxMedicare and taxState. i.e

taxTotal = taxFed + taxSS + taxMedicare + taxState;

The employee's net pay (netPay) is his or her federal taxable gross pay minus total taxes, i.e

netPay = fedTaxGrossPay taxTotal;

The program shall then open an output file named Payroll.txt for writing and shall output the paycheck in the following format,

-------------------------------- EMPLOYEE #1: Smith, John

PAY RATE: $ 15.25 HOURS: 84.00 GROSS PAY: $ 1311.50 MED INS DEDUCT: $ 110.13 401K DEDUCT: $ 78.69 FED TAX GROSS PAY: $ 1122.68 TAX - FEDERAL: $ 89.48 TAX - SS: $ 69.61 TAX - MEDICARE: $ 16.28 TAX - STATE: $ 38.62 TAX - TOTAL: $ 213.98 NET PAY: $ 908.70 --------------------------------

Note:

All real numbers are printed with two decimal digits.

The dollar amounts are all printed right-justified in a field of width 8.

Employee number changes from 1 to 2, 3, etc.

3. Sample Run

Enter the input file name: EmployeeInfo.txt Press any key to continue . . .

4. Misce. Programming Requirements

Your program must also meet the specifications stated as below:

See the sample output file at the end of the specification.

Pick and use identifiers which are self-descriptive. One-letter variable names should not be used. As an example, if you were referring to the ticket price, the variable needed might be declared as double price; instead of double x;

Input:

Smith John 15.25 84.0 2 Johnson Olivia 75.25 90.0 0 Bond James 60.75 80.0 1 Duck Donald 45.75 75 0 Mouse Micky 55.00 80.0 1 Poor Joe 10.00 120.0 2 Rich Lawyer 350.00 40.0 1 

Output:

-------------------------------- EMPLOYEE #1: Smith, John PAY RATE: $ 15.25 HOURS: 84.00 GROSS PAY: $ 1311.50 MED INS DEDUCT: $ 110.13 401K DEDUCT: $ 78.69 FED TAX GROSS PAY: $ 1122.68 TAX - FEDERAL: $ 89.48 TAX - SS: $ 69.61 TAX - MEDICARE: $ 16.28 TAX - STATE: $ 38.62 TAX - TOTAL: $ 213.98 NET PAY: $ 908.70 -------------------------------- -------------------------------- EMPLOYEE #2: Johnson, Olivia PAY RATE: $ 75.25 HOURS: 90.00 GROSS PAY: $ 7148.75 MED INS DEDUCT: $ 32.16 401K DEDUCT: $ 428.93 FED TAX GROSS PAY: $ 6687.66 TAX - FEDERAL: $ 1304.09 TAX - SS: $ 414.64 TAX - MEDICARE: $ 96.97 TAX - STATE: $ 517.63 TAX - TOTAL: $ 2333.33 NET PAY: $ 4354.34 -------------------------------- -------------------------------- EMPLOYEE #3: Bond, James PAY RATE: $ 60.75 HOURS: 80.00 GROSS PAY: $ 4860.00 MED INS DEDUCT: $ 64.97 401K DEDUCT: $ 291.60 FED TAX GROSS PAY: $ 4503.43 TAX - FEDERAL: $ 878.17 TAX - SS: $ 279.21 TAX - MEDICARE: $ 65.30 TAX - STATE: $ 348.57 TAX - TOTAL: $ 1571.25 NET PAY: $ 2932.18 -------------------------------- -------------------------------- EMPLOYEE #4: Duck, Donald PAY RATE: $ 45.75 HOURS: 75.00 GROSS PAY: $ 3431.25 MED INS DEDUCT: $ 32.16 401K DEDUCT: $ 205.88 FED TAX GROSS PAY: $ 3193.22 TAX - FEDERAL: $ 622.68 TAX - SS: $ 197.98 TAX - MEDICARE: $ 46.30 TAX - STATE: $ 247.15 TAX - TOTAL: $ 1114.11 NET PAY: $ 2079.10 -------------------------------- -------------------------------- EMPLOYEE #5: Mouse, Micky PAY RATE: $ 55.00 HOURS: 80.00 GROSS PAY: $ 4400.00 MED INS DEDUCT: $ 64.97 401K DEDUCT: $ 264.00 FED TAX GROSS PAY: $ 4071.03 TAX - FEDERAL: $ 793.85 TAX - SS: $ 252.40 TAX - MEDICARE: $ 59.03 TAX - STATE: $ 315.10 TAX - TOTAL: $ 1420.38 NET PAY: $ 2650.65 -------------------------------- -------------------------------- EMPLOYEE #6: Poor, Joe PAY RATE: $ 10.00 HOURS: 120.00 GROSS PAY: $ 1400.00 MED INS DEDUCT: $ 110.13 401K DEDUCT: $ 84.00 FED TAX GROSS PAY: $ 1205.87 TAX - FEDERAL: $ 96.11 TAX - SS: $ 74.76 TAX - MEDICARE: $ 17.49 TAX - STATE: $ 41.48 TAX - TOTAL: $ 229.84 NET PAY: $ 976.03 -------------------------------- -------------------------------- EMPLOYEE #7: Rich, Lawyer PAY RATE: $ 350.00 HOURS: 40.00 GROSS PAY: $14000.00 MED INS DEDUCT: $ 64.97 401K DEDUCT: $ 840.00 FED TAX GROSS PAY: $13095.03 TAX - FEDERAL: $ 2553.53 TAX - SS: $ 811.89 TAX - MEDICARE: $ 189.88 TAX - STATE: $ 1013.56 TAX - TOTAL: $ 4568.86 NET PAY: $ 8526.17 -------------------------------- 

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions