Question
I just need help in how to get the gross pay and the rest of the calculations so far my code works great, but I'm
I just need help in how to get the gross pay and the rest of the calculations so far my code works great, but I'm stuck on how to calculate the gross pay.
Here is my code:
***************************************************************/ #include #include #include using namespace std;
//Symbolic Constants
//Declare Funtions /* Function that gets an integer value from the user that is within a specific range. It takes three arguments: a string that is used as a prompt to the user to indicate what should be entered, an integer that represents the smallest integer value that can be entered, and an integer that represents the largest integer value that can be entered. It returns an integer: the integer value that is within the specific range. */
int validInt( string prompt, int lower_bound, int upper_bound);
/* function that gets the hourly wage for the employee. The value must be between 0.00 and 30.00 and save the value that is returned from the validDouble function in a double variable. */
double validDouble( string prompt, double lower_bound, double upper_bound );
/* function that gets the number of exemptions the employee claimed. The value must be between 0 and 5 and save the value that is returned from the validInt function in an integer variable. */
int ValidInt( string prompt, int lower_bound2, int upper_bound2);
/* grossPay function that calculates the employee's gross payment amount and pass the hourly wage for the employee (the double value returned from the validDouble call) and the number of hours the employee worked (the integer value returned from the first validInt call) to the grossPay function. The value that is returned from the grossPay function should be saved in a double variable. */ double grossPay( double wage, int hours_worked );
int main() { //Declare Variables int hours_worked, exem; int lower_bound, lower_bound2, upper_bound2; int upper_bound; double lower_bound1; double upper_bound1; double wage, result1; //Get the hours worked hours_worked = validInt("Enter the number of hours worked (0...60):", lower_bound, upper_bound); // Get the hourly wage wage = validDouble("Enter the hourly wage (0.00...30.00):", lower_bound1, upper_bound1); // Get the number of exemptions the employee claimed exem = ValidInt("Enter the number of exemptions (0...5):", lower_bound2, upper_bound2);
// Get the grosspay result1 = grossPay( double wage, int hours_worked); //display the result // cout
/* Function that gets an integer value from the user that is within a specific range. It takes three arguments: a string that is used as a prompt to the user to indicate what should be entered, an integer that represents the smallest integer value that can be entered, and an integer that represents the largest integer value that can be entered. It returns an integer: the integer value that is within the specific range. */
int validInt( string prompt, int lower_bound, int upper_bound ) { int hours_worked; lower_bound = 0; upper_bound = 60; //Get a value from the user and save it in userVal cout > hours_worked; //validate the user's value while( hours_worked = upper_bound ) { cout > hours_worked; } //return the user's value return hours_worked; } /* function that gets the hourly wage for the employee. The value must be between 0.00 and 30.00 and save the value that is returned from the validDouble function in a double variable. */ double validDouble( string prompt, double lower_bound1, double upper_bound1 ) { double wage; lower_bound1 = 0.00; upper_bound1 = 30.00; //Get a value from the user and save it in userVal cout > wage; //validate the user's value while( wage = upper_bound1 ) { cout > wage; } //return the user's value in double data return wage; }
/* function that gets the number of exemptions the employee claimed. The value must be between 0 and 5 and save the value that is returned from the validInt function in an integer variable. */
int ValidInt(string prompt, int lower_bound2, int upper_bound2) { int exemption; lower_bound2 = 0; upper_bound2 = 5; //Get a value from the user and save it in value2 cout > exemption; //validate the user's value while( exemption upper_bound2 ) { cout > exemption; } //return the user's value return exemption; } /* grossPay function that calculates the employee's gross payment amount and pass the hourly wage for the employee (the double value returned from the validDouble call) and the number of hours the employee worked (the integer value returned from the first validInt call) to the grossPay function. The value that is returned from the grossPay function should be saved in a double variable. */ double grossPay(double wage, int hours_worked ) { //declare variables double gross_pay; if( hours_worked For this assignment, write a program that uses function to calculate the weekly payment amount for an employee of Purple Prose Press. The employee's weekly payment amount is based on: 1. The number of hours worked - (minimum: 0, maximum: 60) 2. The hourly wage - (minimum: $0.00, maximum: $30.00) 3. The number of exemptions - (minimum: 0, maximum: 5) The three values will be used to calculate: 1. Gross payment amount 2. Federal income tax withheld 3. State income tax withheld 4. Social Security withheld 5. Net pay amount Declare any variables that are needed. Call the validInt function that is described below to get the number of hours the employee worked. The value must be between 0 and 60 as mentioned above. Make sure to save the value that is returned from the validInt function in an integer variable. Call the validDouble function that is described below to get the hourly wage for the employee. The value must be between 0.00 and 30.00 as mentioned above. Make sure to save the value that is returned from the validDouble function in a double variable. Call the validint function that is described below to get the number of exemptions the employee claimed. The value must be between 0 and 5 as mentioned above. Make sure to save the value that is returned from the validint function in an integer variable. Call the grossPay function that is described below to calculate the employee's gross payment amount. Make sure to pass the hourly wage for the employee (the double value returned from the validDouble call) and the number of hours the employee worked (the integer value returned from the first validInt call) to the grossPay function. The value that is returned from the grossPay function should be saved in a double variable. Call the federalTax function that is described below to calculate the amount of federal income tax that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) and the number of exemptions the employee claimed (the integer value returned from the second validInt call) to the federalTax function. The value that is returned from the federalTax function should be saved in a double variable. Call the state Tax function that is described below to calculate the amount of state income tax that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) and the number of exemptions the employee claimed (the integer value returned from the second validInt call) to the state Tax function. The value that is returned from the state Tax function should be saved in a double variable. Call the socialSecurity function that is described below to calculate the amount of social security that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) to the socialSecurity function. The value that is returned from the socialSecurity function should be saved in a double variable. Call the netPay function that is described below to calculate the employee's net payment amount. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call), the amount of federal income tax that is withheld from the employee (the double value returned from the federalTax call), the amount of state income tax that is withheld from the employee (the double value returned from the state Tax call), and the amount of social security that is withheld from the employee (the double value returned from the socialSecurity call) to the netPay function. The value that is returned from the netPay function should be saved in a double variable. 10+ Run 1 Enter the number of hours worked (0...60): -8 The value must be between (0...60). Try again: 65 The value must be between (0...60). Try again: 60 Enter the hourly wage (0.00...30.00): -5 The value must be between (0.00...30.00). Try again: 45 The value must be between (0.00...30.00). Try again: 30 Enter the number of exemptions (0...5): -9 The value must be between (0...5). Try again: 7 The value must be between (0...5). Try again: 2 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.53 Run 2 Enter the number of hours worked (0...60): 32 Enter the hourly wage (0.00...30.00): 14.25 Enter the number of exemptions (0...5): 0 You worked 32 hours at $14.25 per hour. Gross Pay 456.00 Federal Tax 68.40 State Tax 13.68 Social Security 34.88 Net Pay 339.04 For this assignment, write a program that uses function to calculate the weekly payment amount for an employee of Purple Prose Press. The employee's weekly payment amount is based on: 1. The number of hours worked - (minimum: 0, maximum: 60) 2. The hourly wage - (minimum: $0.00, maximum: $30.00) 3. The number of exemptions - (minimum: 0, maximum: 5) The three values will be used to calculate: 1. Gross payment amount 2. Federal income tax withheld 3. State income tax withheld 4. Social Security withheld 5. Net pay amount Declare any variables that are needed. Call the validInt function that is described below to get the number of hours the employee worked. The value must be between 0 and 60 as mentioned above. Make sure to save the value that is returned from the validInt function in an integer variable. Call the validDouble function that is described below to get the hourly wage for the employee. The value must be between 0.00 and 30.00 as mentioned above. Make sure to save the value that is returned from the validDouble function in a double variable. Call the validint function that is described below to get the number of exemptions the employee claimed. The value must be between 0 and 5 as mentioned above. Make sure to save the value that is returned from the validint function in an integer variable. Call the grossPay function that is described below to calculate the employee's gross payment amount. Make sure to pass the hourly wage for the employee (the double value returned from the validDouble call) and the number of hours the employee worked (the integer value returned from the first validInt call) to the grossPay function. The value that is returned from the grossPay function should be saved in a double variable. Call the federalTax function that is described below to calculate the amount of federal income tax that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) and the number of exemptions the employee claimed (the integer value returned from the second validInt call) to the federalTax function. The value that is returned from the federalTax function should be saved in a double variable. Call the state Tax function that is described below to calculate the amount of state income tax that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) and the number of exemptions the employee claimed (the integer value returned from the second validInt call) to the state Tax function. The value that is returned from the state Tax function should be saved in a double variable. Call the socialSecurity function that is described below to calculate the amount of social security that is withheld from the employee. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call) to the socialSecurity function. The value that is returned from the socialSecurity function should be saved in a double variable. Call the netPay function that is described below to calculate the employee's net payment amount. Make sure to pass the employee's gross payment amount (the double value returned from the grossPay call), the amount of federal income tax that is withheld from the employee (the double value returned from the federalTax call), the amount of state income tax that is withheld from the employee (the double value returned from the state Tax call), and the amount of social security that is withheld from the employee (the double value returned from the socialSecurity call) to the netPay function. The value that is returned from the netPay function should be saved in a double variable. 10+ Run 1 Enter the number of hours worked (0...60): -8 The value must be between (0...60). Try again: 65 The value must be between (0...60). Try again: 60 Enter the hourly wage (0.00...30.00): -5 The value must be between (0.00...30.00). Try again: 45 The value must be between (0.00...30.00). Try again: 30 Enter the number of exemptions (0...5): -9 The value must be between (0...5). Try again: 7 The value must be between (0...5). Try again: 2 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.53 Run 2 Enter the number of hours worked (0...60): 32 Enter the hourly wage (0.00...30.00): 14.25 Enter the number of exemptions (0...5): 0 You worked 32 hours at $14.25 per hour. Gross Pay 456.00 Federal Tax 68.40 State Tax 13.68 Social Security 34.88 Net Pay 339.04
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started