Computer Science 180 .edu



Computer Science 172

Lab 4 - A Wage Calculator

1) Download the program for this lab from the course webpage and then open it in ADAGide. Read through the program and make certain that you understand what the program does and how it works.

2) Execute the program with the following inputs. Show the output that the program gives.

a) Wage: $10.00, Hours worked: 39.0 _______________

b) Wage: $10.00, Hours worked: 40.0 _______________

c) Wage: $10.00, Hours worked: 41.0 _______________

If a person earns $10.00 an hour, why is the pay for working 41 hours $415.00 instead of $410.00? Write your answer below:

__________________________________________________________________

3) People who work for the company for 12 or more months have their base wage increased by 7%. Perform the following steps to add this capability to the program:

a) Declare a constant in the program called Wage_Increase with a value of 0.07.

b) Declare an integer variable in the program called Months_Worked.

c) Declare a constant called Long_Tenure with a value of 12.

d) Give a relational expression using the variable Months_Worked and the constant Long_Tenure that is True if the worker should get a wage increase, and false otherwise. Write your relational expression here:

_______________________________________________

e) Suppose that the worker is eligible for the wage increase. After the program figures the pay (including overtime, if any) it should determine whether or not to increase that value by 7%. (question continues on next page)

Give an assignment statement that will calculate the worker's pay, including the bonus, from the value stored in the variable Pay. Store the result back in the variable Pay. Use the constant Wage_Increase in your calculation. Write your answer below.

_______________________________________________

f) Modify the program to prompt the user for the number of months they have worked, and store that value in the appropriate variable.

g) Combine the relational expression and the assignment statement you wrote above into an if-then or if-then-else statement, as appropriate. The statement should adjust the worker's pay if they are eligible for a wage increase, and do nothing otherwise. Add this statement to the program after the if-then-else statement that calculates any overtime.

4) Employees have the choice of either high-cost or low-cost insurance. High-cost insurance has a $320.00 premium. Low-cost insurance has a $240.00 premium. Modify the program as follows:

a) Declare constants with values of 320.00 and 240.00. Be sure the constants have meaningful names.

b) Declare a string variable of length 1 called Insurance_Type.

c) Add a statement to prompt the user for their insurance type. You should assume that the user will enter "H" for high-cost and "L" for low-cost. Store the user's answer in the variable Insurance_Type.

d) Add an if-then or if-then-else statement to the appropriate place in the program. This statement should check the type of insurance and subtract the appropriate premium from the employee's pay before it is printed.

5) Run your program with various inputs until you are certain that it works correctly for all the possible options. Do not worry about what happens when the worker does not earn enough to cover their insurance costs.

6) Modify the comments as appropriate.

What to turn in: When you have finished with the program, print out a copy of the listing file. Write your names at the top of this lab sheet, staple it on top of the listing file and turn it in.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download