MCC - Marquez - CIS162AB - C++ Level I
P03 Employee Weekly Pay Calculator with Data Validation - 25 points
(turn in source code and sample output)
   cpp.gif


The purpose of this C++ programming project is to familiarize the student with the concept of flowcontrol using while, do-while, and if statements.
Note: Use Ctrl-C while executing a program to terminate an endless loop.

This program will be used by employees to determine what their weekly net pay 
would be based on their hourly rate and number of hours worked.

Use constant variables to store the following values:
     UNION_DUES   = 10.00        FICA_RATE  =  6% (0.06)  OVERTIME_RATE = 1.5
     FEDERAL_RATE = 15% (0.15)   STATE_RATE =  5% (0.05)

The user will be asked to input their hourly rate and number of hours worked. 
The data entered will be validated.
    The hourly rate  must be between $10.00 and $15.00 inclusive (10-15). 
    The hours worked must be between 1 and 50 inclusive (1-50).
The program should then calculate gross and net pay using the user input and 
    constants provided.
For the hours over 40 the employee gets paid 1.5 times their rate.
In addition, the net hourly rate will also be calculated and displayed, so that 
    employees will know what their take-home pay per hour is.
The values entered by the user should be echoed back.
The results should be displayed aligned on the screen with an appropriate label 
    preceding the value.
The amounts should line up under each other after their labels (see sample output).
The rates used to calculate FICA, federal, and state tax should be displayed
    after each of the corresponding amounts.
The output should be formatted to two decimal points. 
You can choose your own variable names, but the formulas to use are:

     if (hours > 40)
        gross   = (40 * rate) + ((hours - 40) * rate * OVERTIME_RATE);
     else
        gross   = hours * rate;

     fica       = gross * FICA_RATE;
     federal    = gross * FEDERAL_RATE;        
     state      = gross * STATE_RATE;
     netpay     = gross - (fica + federal + state + UNION_DUES);
     netHourly  = netpay / hours;


Requirements:
Source code listing and sample output for each case (include rejections).

Use a do-while loop to get the hourly rate.
Use a while loop to get the hours.
Use a if-else statement to determine if the overtime formula should be applied.  

Use these cases to test your program:
 
   Case #     Rate   Worked                Case #     Rate   Worked
   ------    -----     ----                ------    -----     ----
      1       9.25       25   (rejected)      3      15.00       60  (rejected)
      2      12.50       40                   4      15.00       45


Pipe Character Reminder:

  The Or operator is two pipe characters next to each other.
  Where is the pipe character on the keyboard?
  On most keyboards:
    It is right above the Enter key
    Shares the key with the back slash - \
    Must hold the shift key go get it
    Instead of a solid line, it is shown as a broken line
  For the Or operator, 2 pipe characters must be entered - ||.
	
Output Reminder:
  If execution does not pause so that the output can be reviewed, 
  be sure to select Start Without Debugging from the Debug menu.

Sample Output:

Note: Your program does NOT need to display the "case 1 rejected" message. 
It has been added to this sample output to point out what is to occur.

Do NOT add logic to your program that will make it go all the way back to the 
begining of the program.  After a case is rejected, simply enter the hourly rate 
or hours worked for the next case as presented in the sample output below.

P03 - Juan Marquez   TR 1:00pm

Enter a value between $10 and $15.00 for the hourly rate: 9.25   (case 1 rejected)
Enter a value between $10 and $15.00 for the hourly rate: 12.50

Enter a value between 1 and 50 for the hours worked: 40

Hourly Rate:    12.50
Hours Worked:   40
Gross Pay:      500.00
FICA Tax:       30.00 at 0.06
Federal Tax:    75.00 at 0.15
State Tax:      25.00 at 0.05
Union Dues:     10.00
Net Pay:        360.00
Net Hourly:     9.00

Thank you!

P03 - Juan Marquez   TR 1:00pm

Enter a value between $10 and $15.00 for the hourly rate: 15

Enter a value between 1 and 50 for the hours worked: 60          (case 3 rejected)
Enter a value between 1 and 50 for the hours worked: 45

Hourly Rate:    15.00
Hours Worked:   45
Gross Pay:      712.50
FICA Tax:       42.75 at 0.06
Federal Tax:    106.88 at 0.15
State Tax:      35.63 at 0.05
Union Dues:     10.00
Net Pay:        517.25
Net Hourly:     11.49

Thank you!

To make sure you understand the requirements, try completing the IPO Chart. 
The IPO Chart does not need to be submitted.
Input Process Output





Constants:





                       
 

Revised: 08/15/2005 - www.mc.maricopa.edu/~marquez/cis162ab/p03_pay_validation.html