Question: The following exercise is taken from https://www.engage-csedu.org/find-resources/program-2-formatted-output-decisions with slight modification. Write a program that will act as a wage calculator for a single user. The

The following exercise is taken from https://www.engage-csedu.org/find-resources/program-2-formatted-output-decisions with slight modification.

Write a program that will act as a wage calculator for a single user. The program should prompt the user to enter the number of hoursthat they worked and their hourly wage. Those values will then be used to calculate:

  • Gross Pay
  • Amount of Deductions
  • Net Pay

TheGross Pay is based upon the number of hours that were worked. If the user worked 40 hours or less,then: GrossPay=hoursworked*hourlywage

If the user worked more than 40 hours, then: GrossPay=40*hourlywage+(hoursworked-40)*hourlywage*1.5

The Amount of Deductions is based upon the gross pay. If the user earned $100.00 or less, the deductions are2% of the gross pay. If the user earned between $100.01 and $500.00, inclusive, the deductions are 5% of thegross pay. If the user earned more than $500.00, the deductionsare 9% of the gross pay.

TheNet Pay is based upon the gross pay and the deductions. NetPay=GrossPay-AmountofDeductions

After all of the values have been calculated, display a simpletable that contains: the number of hours worked,hourly wage, gross pay, amount of deductions, and net pay

The number of hours worked should be an integer value. The dollar amounts should all be double values. Use meaningful variable names.

Validate the inputs as follow:

  1. If a user enters a negative number for worked hour, print out the following messages and terminate the program. You have entered a negative number for worked hour. Terminating the program.
  2. If a user enters a negative number for hourly wage, use a while loop and print out the following message until a correct value is entered. Your hourly wage is less than 0. Please try again:

Here are 2 sample runs of the program. The bold numbers are entered by a user. Example 1: How many hours did you work? -1 You have entered a negative number for worked hour. Terminating the program.

Example 2: How many hours did you work? 15 How much do you make per hour? -1 Your hourly wage is less than 0. Please try again: 9.5

Wage Calculator Hours Worked 15 Hourly Wage 9.50 ------------------------------------ Gross Pay 142.50 Deductions 7.12 ----------------------------------- Net Pay 135.38

Note: You may want to use "\t" and setw(8) to line up the number column in the output. Use cout << fixed << setprecision(2); to print a double with 2 decimal places

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!