CSCI 240 | Spring 2025 |
For this assignment, write a program that will act as a wage calculator for a single user. The program should use the number of hours worked and hourly wage to calculate:
The Gross Pay is the amount that the user is paid before any deductions are applied. Overtime is not a consideration for this assignment, so the gross pay is simply the number of hours worked times the hourly wage.
The Deduction is 9% of the gross pay.
The Net Pay is the gross pay minus the deduction.
The cpp file that is submitted for grading must be named assign2.cpp.
The basic logic for this assignment is similar to what has been done in previous assignments and examples: the user is asked to enter values, calculations are performed, and the results of the calculations are displayed. The new concepts are that the output should be neatly formatted, and a symbolic constant should be used in the calculation.
The program should prompt the user to enter the number of hours that they worked (an integer) and their hourly wage (a double). The prompts to user must be "How many hours did you work? " and "How much do you make per hour? ". There must be exactly 1 space after the question marks.
Use the two input values to calculate the gross pay, amount of deductions, and net pay.
Finally, display a simple table that contains: the number of hours worked, hourly wage, gross pay, amount of deductions, and net pay. Make sure that there are exactly 2 blank lines between the user entering input values and the start of the table. The labels in the table should match what is shown in the Output section below. Except for the title, each line in the table of output should be exactly 27 characters in length, with the labels being left justified and the displayed values right justified. The monetary values should be displayed with exactly 2 digits after the decimal point.
This program MUST use a symbolic constant to represent the 9% deduction percentage.
At the top of your C++ source code, include a documentation box that resembles the one from program 1.
Include line documentation. There is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describes what the "chunk" of code does. This will also be a part of every program that is submitted for the remainder of the semester.
The dollar amounts should all be displayed with exactly 2 digits after the decimal point, including zeros.
The number of hours worked should be an integer value. The dollar amounts should all be double values. Use meaningful variable names.
Make sure to test the program with values other than the ones supplied in the sample output.
Hand in a copy of the source code (the CPP file) on the autograder and Blackboard.
A few runs of the program should produce the following results.
How many hours did you work? 30 How much do you make per hour? 11.25 Wage Calculator Hours Worked 30 Hourly Wage 11.25 --------------------------- Gross Pay 337.50 Deductions 30.38 --------------------------- Net Pay 307.12
How many hours did you work? 40 How much do you make per hour? 13.45 Wage Calculator Hours Worked 40 Hourly Wage 13.45 --------------------------- Gross Pay 538.00 Deductions 48.42 --------------------------- Net Pay 489.58
How many hours did you work? 51 How much do you make per hour? 9.8524 Wage Calculator Hours Worked 51 Hourly Wage 9.85 --------------------------- Gross Pay 502.47 Deductions 45.22 --------------------------- Net Pay 457.25