I have to write this program, and I am not sure exactly how to write the functions and where to put what. I have tried several times, and decided to start over from the beginnning. What i have so far is at the very bottom.

Here is the prompt:

Overview

For this assignment, write a program that will calculate weekly pay for an employee of XYZ Distributors. The program will run as long as the user enters ‘y’ or ‘Y’ when they are asked if they want to calculate weekly pay.

The program should first ask the user if he/she wants to calculate their pay amount for a week. If the user enters a ‘y’ or ‘Y’, it should then ask the user for three values:

The number of hours worked - (minimum: 0, maximum: 60)

The hourly wage - (minimum: $0.00, maximum: $30.00)

The number of exemptions - (minimum: 0, maximum: 5)

The three values will then be used to calculate:

Gross pay

Net pay

Social Security

Federal income tax

State income tax

The formula for Net pay is:

Net pay = Gross pay - (Social security + Federal income tax + State income tax)

Once the user does not want to calculate weekly pay, display the total gross pay, total net pay, and a bargraph of asterisks that is equal to the number of weeks that weekly pay has been calculated. The total values should only be displayed if the user calculated one or more weeks worth of pay.

Functions that you must write:

1) double CalculateGrossPay( double wage, int hoursWorked )

The purpose of this function is to calculate and return an employee’s gross pay for one week. It takes two arguments: a double representing the employee’s hourly wage and an integer representing the number of hours that the employee worked for one week.

The maximum number of hours that an employee can work before they start to earn overtime pay is 40 hours. If the number of hours worked is less than or equal to 40, gross pay is equal to the hourly wage times the number of hours worked. If the number of hours worked is greater than 40, the gross pay is equal to 40 times the hourly wage plus 1.5 times the hourly wage for every hour over 40.

2) double CalculateFederalTax( double grossPay, int numExemptions )

The purpose of this function is to calculate and return the federal income tax to withhold from an employee. It takes two arguments: a double that represents the employee’s gross pay and an integer argument that represents the number of exemptions claimed by the employee.

The federal withholding allowance for a weekly pay period is $55.77. The amount of the employee’s gross pay that is subject to federal taxation is equal to gross pay minus (the federal withholding allowance times the number of exemptions). The amount subject to taxation is then used to calculate the federal income tax to withhold. The amount to withhold can be calculated using the following table:

Amount subject to taxation(X)-----Amount to withhold

X < $51------------------------------$0

$51 < X < $552--------------------15% of X

$552 < X < $1196------------------$75.15 plus 28% of X greater than $552

$1196 < X < $2662-----------------$255.47 plus 31% of X greater than $1196

$2662 < X < $5750-----------------$709.93 plus 36% of X greater than $2662

$5750 < X---------------------------$1821.61 plus 39.6% of X greater than $5750

If an employee’s gross pay is $1600.00 and they have 2 exemptions, the amount of federal income tax withheld is $346.13.

Amount subject to taxation = 1600.00 - (55.77 * 2) = 1488.46

31% of amt sub. to taxation > $1196 = 0.31 * (1488.46 - 1196) = 90.66

Amount to withhold = 255.47 + 90.66 = 346.13

3) double CalculateStateTax( double grossPay, int numExemptions )

The purpose of this function is to calculate and return the state income tax to withhold from an employee. It takes two arguments: a double that represents the employee’s gross pay and an integer that represents the number of exemptions claimed by the employee.

The state exemption amount for a weekly pay period is $38.46. If the employee’s gross pay is less than or equal to the state exemption amount times the number of exemptions, the amount of the state income tax to withhold is $0.00. If the employee’s gross pay is greater than the state exemption amount times the number of exemptions, the amount of state income tax to withhold is equal to 3% of (gross pay minus (the state exemption amount times the number of exemptions)).

4) double CalculateSocialSecurity( double grossPay )

The purpose of this function is to calculate and return the amount of social security to withhold from an employee. It takes one argument: a double that represents the employee’s gross pay.

The amount of social security to withhold from the employee is equal to 7.65% of the employee’s gross pay.

5) int ValidInt( string prompt, int lowerBound, int upperBound )

The purpose of this function is to get an integer from the user that is within a certain range. It takes three arguments: a string that is used as a prompt to the user to tell them what number they are entering, an integer that represents the smallest integer that the user can enter, and an integer that represents the largest integer that the user can enter.

The second and third arguments will be used to ensure that the user enters a valid value. If an invalid value is entered, display an error message and prompt the user to re-enter a value. This should be done repeatedly until the user enters a valid integer. The function returns the valid integer.

A calling statement like: num = ValidInt( "Enter a 2 digit number", 10, 99 );

Should produce the following prompt: Enter a 2 digit number (10...99):

6) double ValidDouble( string prompt, double lowerBound, double upperBound )

This function is exactly like ValidInt, except that it takes two doubles, rather than integers.

7) void BarGraph( int numWeeks )

The purpose of this function is to display a line of asterisks equal to the number of weeks that weekly pay has been calculated. It takes one argument: an integer that represents the number of weekly pay calculations that have been performed. This function returns nothing.

Programming Requirements:

Define symbolic constants for the federal withholding allowance ($55.77), the state exemption amount ($38.46), and the social security percentage (7.65%). You may use more symbolic constants if you desire, but you must have at least the three listed above.

Use the ValidInt function to get the number of hours worked and the number of exemptions from the user.

Use the ValidDouble function to get the hourly wage amount from the user.

The program should run as long the user enters ‘y’ or ‘Y’. Use one of the "to" functions to avoid having to code a compound condition.

Display the week number before displaying the gross pay, taxes, social security, and net pay. (see sample output)

Your program must be fully documented. There must be a documentation box for every function in the program. Line documentation should be used wherever needed, but need not be on every line of code. White space and indentation should be used to make your code easily readable.

Sample Output:

Would you like to calculate your weekly pay? Y

Enter the number of hours worked (0...60): 60

Enter the hourly wage (0.00...30.00): 30.00

Enter the number of exemptions (0...5): 2

Week 1:

You worked 60 hours at $30.00 per hour.

Gross Pay: 2100.00

Federal Tax: 501.13

State Tax: 60.69

Social Security: 160.65

Net Pay: 1377.52

Would you like to calculate your weekly pay? n

Total Gross Pay: 2100.00

Total Net Pay: 1377.52

Total Number of Weeks: *

Here is what I have done so far. Not sure if it is really correct to start with....

```
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
#define FEDERAL_WITHHOLDING 55.77
#define STATE_EXEMPTION 38.46
#define SOCIAL_SECURITY .0765
// Setting up all prototypes for the functions
double CalculateGrossPay( double, int );
double CalculateFederalTax( double, int );
double CalculateStateTax( double, int );
double CalculateSocialSecurity( double );
int ValidInt( string, int , int );
double ValidDouble( string, double, double );
void BarGraph( int );
int main()
{
cout << endl;
system ("pause");
return 0;
}
// Setting up all functions
/*****************************************************************************
double CalculateGrossPay( )
The purpose of this function is to calculate and return an employee’s gross
pay for one week. It takes two arguments: a double representing the employee’s
hourly wage and an integer representing the number of hours that the employee
worked for one week.
*****************************************************************************/
double CalculateGrossPay( double wage, int hoursWorked )
{
int hours;
double wage;
double grossPay;
cout << "Enter the amount of hours worked this week (0...60): ";
cin >> hours;
cout << "Enter the hourly wage (0.00...30.00): ";
cin >> wage;
if ( hours > 40)
{
grossPay = (40 * wage) + ((hours - 40) * wage * 1.5)
}
else
{
grossPay = hours * wage
}
return grossPay;
}
/*****************************************************************************
double CalculateFederalTax( )
The purpose of this function is to calculate and return the federal income tax
to withhold from an employee. It takes two arguments: a double that represents
the employee’s gross pay and an integer argument that represents the number of
exemptions claimed by the employee.
*****************************************************************************/
double CalculateFederalTax( double grossPay, int numExemptions )
{
int exemptions;
double taxationAmount;
cout << "Enter the number of exemptions: ";
cin >> exemptions;
taxationAmount = grossPay - (FEDERAL_WITHHOLDING * exemptions)
switch ( X )
case taxationAmount < 51:
case taxationAmount >= 51 || taxationAmount < 552:
case taxationAmount >= 552 || taxationAmount < 1196:
case taxationAmount >= 1196 || taxationAmount < 2662:
case taxationAmount >= 2662 || taxationAmount < 5750:
case taxationAmount >= 5750:
}
/*****************************************************************************
double CalculateStateTax( )
The purpose of this function is to calculate and return the state income tax
to withhold from an employee. It takes two arguments: a double that represents
the employee’s gross pay and an integer that represents the number of exemptions
claimed by the employee.
*****************************************************************************/
double CalculateStateTax( double grossPay, int numExemptions )
{
}
/*****************************************************************************
double CalculateSocialSecurity( )
The purpose of this function is to calculate and return the amount of social
security to withhold from an employee. It takes one argument: a double that
represents the employee’s gross pay.
*****************************************************************************/
double CalculateSocialSecurity( double grossPay )
{
}
/*****************************************************************************
int ValidInt( )
The purpose of this function is to get an integer from the user that is within
a certain range. It takes three arguments: a string that is used as a prompt
to the user to tell them what number they are entering, an integer that
represents the smallest integer that the user can enter, and an integer
that represents the largest integer that the user can enter. The second and
third arguments will be used to ensure that the user enters a valid value. If
an invalid value is entered, display an error message and prompt the user to
re-enter a value. This should be done repeatedly until the user enters a valid
integer. The function returns the valid integer.
*****************************************************************************/
int ValidInt( string prompt, int lowerBound, int upperBound )
{
}
/*****************************************************************************
double ValidDouble( )
This function is exactly like ValidInt, except that it takes two doubles,
rather than integers.
*****************************************************************************/
double ValidDouble( string prompt, double lowerBound, double upperBound )
{
}
/*****************************************************************************
void BarGraph( )
The purpose of this function is to display a line of asterisks equal to the
number of weeks that weekly pay has been calculated. It takes one argument: an
integer that represents the number of weekly pay calculations that have been
performed. This function returns nothing.
*****************************************************************************/
void BarGraph( int numWeeks )
{
}
```