Lab
Assignment 3: Using Decisions for Pay Calculations
Goals:
1. Use arithmetic
operators and relational operators
2. Use const keyword to declare a constant data
object
3. Use if / else and switch decision
constructs
4. Develop a flow chart depicting decision structures
5. Format numerical output
Print Assessment Sheet (link)
Description:
Calculate the weekly wage for hourly employees.
Interaction:
Enter employee
number: 1032864
Enter pay code
( M/O/T ): M
Enter hours worked:
41
Example
Output:
Employee #:
1032864
Pay Rate:
$5.15
Hours Worked:
41
Total Pay:
$213.72
Input
Data:
Employee Number
Hours Worked
Pay
Code:
The company has three pay scales:
minimum wage -
pay code 'M'
minimum plus $1.00 - pay code 'O'
minimum plus $2.00 - pay code 'T'
The current minimum wage is _________. (Use the
Internet...find out.)
Test
Data:
Employee
|
Pay Code
|
Hours
|
Pay $$
|
1032864
|
M
|
41
|
|
1171955
|
T
|
38
|
|
1224096
|
O
|
45
|
|
1234567
|
N
|
40
|
|
Submit:
- Turn in Document with the following:
- Logic Plan
- Source code listing
- Output (screen
shots) from test data above
Data
Objects:
const
double MIN_WAGE = ?.??;
Considerations:
Employee gets time and a half for overtime over 40 hours per week. Currency values should be formatted as currency in US dollars.
Program
Logic:
//
initialization
(Did you remember to #include <iomanip>?
Display Programmer Name and Assignment Number.
// input
Prompt operator for Employee Number, Pay Code, and Hours.
Store all keyboard input in data objects you declared.
// processing
Use
switch to assign Pay Rate a value based on Pay Code.
If Pay Code is invalid:
Assign Pay Rate a value of zero
Display an error message to operator
Use if / else to calculate pay based on hours worked:
0 to 40 hours: multiply hours times pay
rate.
Over 40 hours: multiply 40 times pay rate
multiply hours over 40 by 1½ pay rate
add
regular and overtime pay
//
output
Set
precision to round pay to nearest cent.
Display results as shown above.
//
termination
Display normal end of job message
Return
to TOP
|