CSCI 220 Homework Assignment #6

Assigned Date: Monday, March 24, 2003 
Due Date: Wednesday, April 2, 2003 
Due Time: Noon 

Updated: Tuesday, April 01, 2003 11:32 AM

Program file names to be submitted: UsedCar.java, UsedCarDriver.java

Skills Developed: Creating and Calling methods. Program design.

Specification: Ian M. Koole is going to get a job selling used cars. He has been offered three payment arrangements for imbursement for his time:

a) A straight salary of $500 per week b) A salary of $5.00 per hour for a 40-hour work week, plus a 15% commission on sales c) No salary at all, with a 20% commission on sales, plus a flat rate of $10.00 per car sold.

Write a Java program to help Mr. Koole find the best payment option based on different scenarios of sales. Your code should be contained in two java files. UsedCar.java should hold three methods, one for each payment plan above. UsedCarDriver.java should hold the main method that fully tests all of the methods in UsedCar.

Design Phase: Before beginning to write code, think carefully about what each method does, what information is needed from the calling routine in order to perform this task, and what the return-type should be. After considering, write pseudocode for each method.

Implementation Phase: After designing the methods, implement each method. Compile and test before implementing the next method.

Testing Phase: Your test method (main method found in UsedCarDriver.java) should make several calls to each method passing to the methods varying values to fully test them. Don't assume that a calling program will pass in "legitimate" values. It is possible due to data entry errors for a program to pass in negative values when clearly the code needs positive values to run properly. Once in the testing phase, you may find that you need to return back to the design phase of development to add more functionality to your methods.

This assignment is based on a problem found in Oh! Pascal by Doug Cooper and Michael Clancy published in 1982 by Norton and Company. It can be found on page 96, question number 19.

Sample Run:

Enter the hours worked per week (a positive integer): 30

Enter the amount of weekly sales (a positive real): 3500.0

Enter the number of cars sold this week (a positive integer): 3

Possible salaries:

a) Straight weekly salary: $500.0

b) Hourly wages plus commission: $675.0

c) Commission plus bonus per car: $730.0