CIS 122: Assignment #3

Due on Thursday, July 28 2005


Problem 1 (40 points)

Write a program that takes as input an employee's hours worked and regular pay rate, and outputs the employee's wages for the week. Calculate an employee's wages as follows: she receives her regular rate for the first 40 hours, 1.6 times her regular rate for each hour over 40 through 50, and double her regular rate for each hour over 50. For invalid inputs, output the message "INPUT ERROR(S)". (Extra credit part, 10 points) In addition to this, furthur diagnostic messages should appear specifying which input value was out of range or that both were out of range.(There is a minimum wage $8.5 per hour).

Problem 2 (60 points)

Write a program to implement a simple calculator, which has three functions: addition, average and multiplication. The program accepts an input character, either '+', 'a' or '*', which indicates addition, average and multiplication operations separately. Then the program accepts an input integer number indicating the number of operands. Finally, the program reads the operands and provides the output. The belowing is one possible output of this program: (user input is in italics and underlined),

What kind of operations you want, + for addition, a for average and * for multiplication?a
How many operands? 4
Input the operands: 12 33 -16 51
The average of the 4 numbers is 20.

Standards:

Your program will be judged primarily on its correctness. In particular, the program must compile. Programs that do not will receive a severe grade penalty. Over and above this is the requirement of correct behavior: the cubic volume reported must be correct.

Third, there is presentation: prompts should be formatted neatly (exactly matching the example here is good). Both of the two output numbers provided should have two decimal places, which means, they have a precision of two digits after the decimal point.

Finally, your program will be judged on elegance and adherence to the principles of good programming style. Elegance means that there should be nothing there that isn't necessary for the computation: all variables should have a use, as should all assignments to those variables. Style refers to the proper use of indentation, information variable names, documentation with comments, and other matters of readability.

Turn in:


Dan Rao
Last modified: Mon Jul 25 23:22:34 PDT 2005