Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

11:02 AM Wed Mar 3 95% k 240pgm6.htm Basic Logic for int main() Declare any variables that are needed. Call the validInt function that is

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

11:02 AM Wed Mar 3 95% k 240pgm6.htm Basic Logic for int main() 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 valid Int call) to the gross Pay 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 federal Tax 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 social Security call) to the netPay function. The value that is returned from the netPay function should be saved in a double variable. 11:03 AM Wed Mar 3 94% 240pgm6.htm ... k The Functions Write and use the following 7 functions in the program. int validInt( string prompt, int lower_bound, int upper_bound ) This function 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. The function should display the string argument and the two integer values to the user and then get the user's value. A loop should be used to verify the user's value. As long as the user enters a value that is not within the specified range, an error message should be displayed and the user should be given a chance to re-enter the value. Once the user enters a valid value, it should be returned to the caller. As an example of how this function might be used in previous programs, to get an integer value from the user that is between 10 and 99, there might have been something like: cout > num; In this program, the above cout/cin statement should be replaced with: num = validInt("Enter a 2 digit number", 10, 99 ); which should produce a prompt similar to: Enter a 2 digit number (10...99): The actual format of how the prompt and specific range are specified is left up to you, but the display MUST include the range of values. double validDouble( string prompt, double lower_bound, double upper_bound) This function is like validint, except that it works with double values rather than integer values. double grossPay( double wage, int hours_worked ) 11:04 AM Wed Mar 3 994% k 240pgm6.htm double federalTax( double gross_pay, int num_exemptions ) This function calculates and returns the amount of federal income tax to withhold from an employee. It takes two arguments: a double that represents the employee's gross payment amount and an integer argument that represents the number of exemptions claimed by the employee. It returns a double: the amount of federal tax to withhold. 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 the employee's gross payment amount 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). X $1196 = 0.31 * (1488.46 - 1196) = 90.66 Amount to withhold = 255.47 +90.66 = 346.13 double state Tax( double gross_pay, int num_exemptions ) This function calculates and returns the amount of state income tax to withhold from an employee. It takes two arguments: a double that represents the employee's gross payment amount and an integer that represents the number of exemptions claimed by the employee. It returns a double: the amount of state income tax to withold. The state exemption amount for a weekly pay period is $38.46. If the employee's gross payment amount 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 payment amount 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)). 11:04 AM Wed Mar 3 94% - { k 240pgm6.htm The state exemption amount for a weekly pay period is $38.46. If the employee's gross payment amount 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 payment amount 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)). double socialSecurity( double gross_pay) This function calculates and returns the amount of social security to withhold from an employee. It takes one argument: a double that represents the employee's gross payment amount. It returns a double: the calculated amount of social security to withhold from an employee. The amount of social security to withhold from the employee is equal to 7.65% of the employee's gross payment amount. double netPay( double gross_pay, double federal_withhold, double state_withhold, double social_security ) This function calculates and returns the employee's net payment amount. It takes four arguments: a double that represents the gross payment amount, a double that represents the amount of federal tax that is withheld, a double that represents the amount of state tax that is withheld, and a double that represents the amount of social security that is withheld. It returns a double: the calculated net payment amount. The net payment amount is equal to the gross payment amount minus the sum of the amount of federal tax that is withheld, the amount of state tax that is withheld, and the amound of social security that is withheld. Symbolic Constants The program must use at least three symbolic constants. The constants should represent the federal withholding allowance ($55.77), the state exemption amount ($38.46), and the social security percentage (7.65%). Note: keep in mind that the social security constant is a percentage. The value that is assigned to the constant will determine how the constant is used in the socialSecurity function when calculating the amount of social security to withhold. There may be more symbolic constants if needed. Programming Requirements 11:04 AM Wed Mar 3 94% - 240pgm6.htm ... f 2. Honou uvuvugumo vam ugo function to get the hourly wage amount from the user. 3. Hand in a copy of the source code (CPP file) using Blackboard. Output 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 11:02 AM Wed Mar 3 95% k 240pgm6.htm Basic Logic for int main() 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 valid Int call) to the gross Pay 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 federal Tax 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 social Security call) to the netPay function. The value that is returned from the netPay function should be saved in a double variable. 11:03 AM Wed Mar 3 94% 240pgm6.htm ... k The Functions Write and use the following 7 functions in the program. int validInt( string prompt, int lower_bound, int upper_bound ) This function 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. The function should display the string argument and the two integer values to the user and then get the user's value. A loop should be used to verify the user's value. As long as the user enters a value that is not within the specified range, an error message should be displayed and the user should be given a chance to re-enter the value. Once the user enters a valid value, it should be returned to the caller. As an example of how this function might be used in previous programs, to get an integer value from the user that is between 10 and 99, there might have been something like: cout > num; In this program, the above cout/cin statement should be replaced with: num = validInt("Enter a 2 digit number", 10, 99 ); which should produce a prompt similar to: Enter a 2 digit number (10...99): The actual format of how the prompt and specific range are specified is left up to you, but the display MUST include the range of values. double validDouble( string prompt, double lower_bound, double upper_bound) This function is like validint, except that it works with double values rather than integer values. double grossPay( double wage, int hours_worked ) 11:04 AM Wed Mar 3 994% k 240pgm6.htm double federalTax( double gross_pay, int num_exemptions ) This function calculates and returns the amount of federal income tax to withhold from an employee. It takes two arguments: a double that represents the employee's gross payment amount and an integer argument that represents the number of exemptions claimed by the employee. It returns a double: the amount of federal tax to withhold. 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 the employee's gross payment amount 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). X $1196 = 0.31 * (1488.46 - 1196) = 90.66 Amount to withhold = 255.47 +90.66 = 346.13 double state Tax( double gross_pay, int num_exemptions ) This function calculates and returns the amount of state income tax to withhold from an employee. It takes two arguments: a double that represents the employee's gross payment amount and an integer that represents the number of exemptions claimed by the employee. It returns a double: the amount of state income tax to withold. The state exemption amount for a weekly pay period is $38.46. If the employee's gross payment amount 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 payment amount 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)). 11:04 AM Wed Mar 3 94% - { k 240pgm6.htm The state exemption amount for a weekly pay period is $38.46. If the employee's gross payment amount 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 payment amount 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)). double socialSecurity( double gross_pay) This function calculates and returns the amount of social security to withhold from an employee. It takes one argument: a double that represents the employee's gross payment amount. It returns a double: the calculated amount of social security to withhold from an employee. The amount of social security to withhold from the employee is equal to 7.65% of the employee's gross payment amount. double netPay( double gross_pay, double federal_withhold, double state_withhold, double social_security ) This function calculates and returns the employee's net payment amount. It takes four arguments: a double that represents the gross payment amount, a double that represents the amount of federal tax that is withheld, a double that represents the amount of state tax that is withheld, and a double that represents the amount of social security that is withheld. It returns a double: the calculated net payment amount. The net payment amount is equal to the gross payment amount minus the sum of the amount of federal tax that is withheld, the amount of state tax that is withheld, and the amound of social security that is withheld. Symbolic Constants The program must use at least three symbolic constants. The constants should represent the federal withholding allowance ($55.77), the state exemption amount ($38.46), and the social security percentage (7.65%). Note: keep in mind that the social security constant is a percentage. The value that is assigned to the constant will determine how the constant is used in the socialSecurity function when calculating the amount of social security to withhold. There may be more symbolic constants if needed. Programming Requirements 11:04 AM Wed Mar 3 94% - 240pgm6.htm ... f 2. Honou uvuvugumo vam ugo function to get the hourly wage amount from the user. 3. Hand in a copy of the source code (CPP file) using Blackboard. Output 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

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions