CSCI 240 Spring 2025

Assignment 3
Decision Statements
(100 points)


Due: Friday, February 7 on the autograder and Blackboard by 11:59 PM

Overview

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. The gross pay is based upon the number of hours worked. If the number of hours worked is less than or equal to 40, gross pay is equal to the number of hours worked times the hourly wage. If the number of hours worked is greater than 40, the gross pay is equal to the pay for the first 40 hours worked plus overtime pay, which is for any hour over 40 and is paid at 1.5 times the hourly wage for each hour over 40.

The Deduction is based on the user's gross pay. If the gross pay is $150.00 or less, the deduction is 2.3% of the gross pay. If the gross pay is greater than $150.00 and less than or equal to $750.00, the deduction is 5.1% of the gross pay. If the gross pay is greater than $750.00, the deduction is 9.9% of the gross pay.

The Net Pay is equal to the gross pay minus the deduction.

The cpp file that is submitted for grading must be named assign3.cpp.

Basic Program Logic

The basic logic for this program is like what has been done in assignments 1 and 2: the user is asked to enter values, calculations are performed, and the results of the calculations are displayed. The new concept is that different calculations will be performed based on values entered by the user.

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.

Using a decision statement and the number of hours worked, calculate the gross pay using one of the two calculations described above.

Using a cascading decision statement and the calculated gross pay, calculate the deduction amount using one of the three calculations described above.

Calculate the net pay.

Finally, display the wage information in a table. It should include the number of hours worked, hourly wage, pay without overtime plus the number of hours, overtime pay plus the number of overtime hours, gross pay, deduction percentage, deduction amount, and net pay.

The dollar amounts should be displayed with exactly 2 digits after the decimal point. The deduction percentage should be displayed with exactly 1 digit after the decimal point and a trailing percent sign (%).

Use two newline characters before displaying the table title of "Wage Calculator" and a single newline character at the end of the output. Except for the two lines of pay with and without overtime, each line should be exactly 32 characters in length with the labels left-justified and displayed values right-justified.

Symbolic Constants

This program MUST use at least four symbolic constants.

One constant should represent the number of hours to determine if there is overtime. Use an integer value of 40.

The second constant should represent the first deduction percentage of 2.3.

The third constant should represent the second deduction percentage of 5.1.

The fourth constant should represent the third deduction percentage of 9.9.

Program Requirements

  1. At the top of the C++ source code, include a documentation box that resembles the one from Assignments 1 and 2. This will be a part of every assignment that is submitted during the semester and this will be the last reminder in the assignment write-ups.

  2. 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 be a part of every assignment that is submitted during the semester and this will be the last reminder in the assignment write-ups.

  3. The dollar amounts should all be displayed with exactly 2 digits after the decimal point, including zeros.

  4. The deduction percentage should be displayed with exactly 1 digit after the decimal point.

  5. The four symbolic constants must be used in the code. The names must follow C++ naming convention.

  6. Make sure to test the program with values other than the ones supplied in the sample output.

  7. Hand in a copy of the source code (the CPP file) on the autograder and Blackboard.

Output

A few runs of the program should produce the following results:

Run 1

How many hours did you work? 57
How much are you paid per hour? 5.75


Wage Calculator

Hours Worked                  57
Hourly Wage                 5.75
--------------------------------

Pay w/o Overtime          230.00 (40 hours)
Overtime Pay              146.62 (17 hours)
--------------------------------

Gross Pay                 376.62
Deductions (5.1%)          19.21
--------------------------------

Net Pay                   357.42

Run 2

How many hours did you work? 27
How much are you paid per hour? 7.32


Wage Calculator

Hours Worked                  27
Hourly Wage                 7.32
--------------------------------

Pay w/o Overtime          197.64 (27 hours)
Overtime Pay                0.00 (0 hours)
--------------------------------

Gross Pay                 197.64
Deductions (5.1%)          10.08
--------------------------------

Net Pay                   187.56

Run 3

How many hours did you work? 47
How much are you paid per hour? 17.86


Wage Calculator

Hours Worked                  47
Hourly Wage                17.86
--------------------------------

Pay w/o Overtime          714.40 (40 hours)
Overtime Pay              187.53 (7 hours)
--------------------------------

Gross Pay                 901.93
Deductions (9.9%)          89.29
--------------------------------

Net Pay                   812.64

Run 4

How many hours did you work? 32
How much are you paid per hour? 3.47


Wage Calculator

Hours Worked                  32
Hourly Wage                 3.47
--------------------------------

Pay w/o Overtime          111.04 (32 hours)
Overtime Pay                0.00 (0 hours)
--------------------------------

Gross Pay                 111.04
Deductions (2.3%)           2.55
--------------------------------

Net Pay                   108.49