CS 157 Spring 2002
Assignment 5 – While loops (plus If statements, calculations and I/O)
100 points
Assigned: 02/14/2002
Due: 02/21/2002 at the start of class
Pre-Lab (Do Before Lab): Bring a new disk. Plan out sequence of statements needed for program. This is another step up in complexity. Plan ahead!!
Main Assignment:
Acme
Corp is in dire need of a program to keep track of employee pay. Write a program that, given a pay rate and a
number of weeks to track, will get an employee’s hours worked for that many
weeks. For each week, determine if the employee is due overtime pay (and
calculate it if appropriate), and display the week number, hours worked and
total pay (see below). After all weeks have been processed, display the number
of weeks worked, the pay rate, the total pay over the period, and the average
(mean) number of hours worked per week and average (mean) pay per week (see
below).
Sample Interaction with the user (minus user
answers which are typed elsewhere):
Welcome to Acme Corp
What is you base pay rate (in dollars per hour)?
How many weeks are we tracking?
How many hours worked in week #1?
Week: 1 Hours:
30.0 Pay: 180.0
How many hours worked in week #2?
Week: 2 Hours:
50.0 Pay: 330.0
How many hours worked in week #3?
Week: 3 Hours:
60.0 Pay: 420.0
Results:
# Weeks: 3
Pay Rate: 6.0
Total
Pay: 930.0
Ave # Hours /
Week: 46.666666666666664
Ave Pay /
Week: 310.0
Hand in:
Miscellaneous:
·
Overtime pay is
time and a half for EXTRA hours – that is, for each hour worked over 40, the
employee makes 1 ½ times their normal salary for those hours (but only their
regular salary for the first 40 hours).
·
Define named
constants. For instance, federal law could change – changing the number of
hours before overtime is due from 40 to 37. We’d like to be able to make just
one change in our program.
·
Please try to make
the output of your program like mine, to aid my grading. (but note that we
haven’t done anything yet with specifying how many decimal places to display)
·
You will need the SavitchIn.java file (still obtainable
from my WWW page - or from previous
weeks).
·
You can use dialog boxes if you prefer, but make sure
it doesn’t get in your way.
·
MAKE SURE YOUR
PROGRAM WORKS! (i.e. more than just removing compile errors). You can test your
program on the above example, but make sure you test it on other data as well -
I will! Your program needs to be able to handle any valid inputs.
·
If you have any
questions about the overtime scheme, please ask!!! Your calculations need to
meet the requirements of the task.
·
Put YOUR NAME, and
e-mail address in comments at the beginning of the program.
· Remember: Indentation, meaningful variable names, and meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your program in order to get full credit.