CIS 122: Assignment #5

Due on Friday, August 5, 2005


Problem 1 (50 points)

Continue on from the Problem 1 of Assignment 3. Besides calculating the employee's gross wage for the week, you also need to provide her the weekly net income after tax. The tax rate for weekly income of $179 or under is zero; 5% for the part exceeding $179 but within $323; 7% for the part between $323 and $673; 10% for those beyond $673. 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 and her net income after tax. Implement two functions: one takes the working hours and regular pay rate as input, outputs the gross wage; the other function takes the gross wage as input, outputs the net income. For invalid inputs, output the message "INPUT ERROR(S)".(There is a minimum wage $8.5 per hour). The belowing is one possible output of this program: (user input is in italics and underlined),

Enter the hours you worked in this week: 51
Enter your regular pay rate: 15.0
Your gross wage for this week is $870.00.
Tax deduction : $51.40
Your net income for this week is $818.60.
Problem 2 (50 points)

The area of a triangle can be calculated from the lengths a, b and c of its sides using Hero's formula:

[Note: If a, b, and c can not be the lengths of the sides of a triangle, then the quantity s(s-a)(s-b)(s-c) will be negative or zero.]

Write a program to input the lengths of the sides of a triangle; then output the area of the triangle or a message saying that the lengths can not be those of the sides of a triangle. Use a double-valued function to calculate the triangle area.

Extra creidts (5 points): implement one more function of your own design, either for getting user's input or outputting the results.

For your interest ONLY:

Cryptographic algorithms

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 August 1 23:22:34 PDT 2005