Program4

Document Sample

```					                                                Program 4
Arrays, Class Design, Decision Structures, and Loops
Pseudocode Due Date: Friday, October 16, noon. (This part is worth 15 homework points.)
Program Due Date: Friday, October 23, noon. (This program is worth 50 programming points.)

Reminder:
All programming assignments in this course are individual assignments. You are allowed to discuss the program
logic with and/or get help from your lecture instructor only!

The Problem:

Assume that you have been hired as a software developer for a car dealership company. You job is to write an
application (call it CarLoanVsLeaseApp) to process a collection of cars that the company has just acquired and are
now available for customer. For each car, get input from the user for the make, model, year of manufacture, base
price, picture URL, and number of payments (months). You need to create a Car class to model this information
(see below for the instance variable/fields/attributes and methods). With the information gathered, you are to
produce a report that computes the monthly loan and lease payments for each of the cars using a … Web service
(you guessed it! ) The interest rate and sales tax for the app will be constant and so you should make sure that you
implement this appropriately. What is the average lease payment versus the average traditional loan payment for all
the cars? You need to display these values at the end of the report. Format the output using standard currency where
applicable. The web service information is available at http://www.webservicex.net/FinanceService.asmx?wsdl.

Your Car class should have the following attributes (instance variables):

       Make of the vehicle
       Model of the vehicle
       Year
       Price
       Picture URL
       Length of term
       Residual Value (for the lease calculation)
       Constants for sales tax (7.25%) and interest (5.65%).
       Use appropriate types for each attribute, and make sure that all attributes have the correct access specifiers.
All other variables should be created when needed within the appropriate method. Penalty points will be
imposed for incorrect use of instance variables for local variables.

Your Car class should have the following methods:

     A no-arg/default constructor (one that takes no parameters). Use “” (empty string) as the default make and
model. All other variables (except constants) should be 0 or 0.0.
     A constructor that accepts all attributes.
     Accessors (getters) for all instance data
     Mutators (setters) for all instance data
     readCarInfo method that prompts the user for all information, then reads and stores that input. This
method has no parameters and does not return anything.
     computeTotalPrice method that computes and returns the total price for a car by adding the tax
amount to the price. This method has no parameters, and returns the total as a double. This method must be
used (called from elsewhere in your class).
     computeLoan method that computes and returns the loan payment for a car. This method takes no
parameters and returns the loan payment as a double. Again, the rate is 5.65%. This method must be used
(called from elsewhere in your class).
    computeLease method that computes and returns the lease payment for a car. This method takes no
parameters and returns the lease payment as a double. Again, the rate is 5.65%. This method must be used
(called from elsewhere in your class).
    printACar method that prints to the console the car and loan/lease information, that is, the name, make
and model, year, base price, tax, total price, length of term, picture (using the URL given), lease amount
and loan amount for each of car. The method should convert the make and model to uppercase, nicely
format the dollar amounts, line things up in columns, and add a decorative header and footer to the output.

Other Details:

1.   Your app should allow for a maximum of 100 cars to be processed (the company has only that much space
to place all the cars). Beyond that, you should display appropriate error messages.
2. Your program should read the car information one at a time into an array and stop when the sentinel value
of “xxx” is entered for the make of the car.
3. You can assume that all data entered will be of the correct type.
4. Be sure to compute and display the average lease payment and average traditional payment at the end
of the report.
5. Dollar amounts should be formatted as standard currency.

Submission Requirements:

    Create a class diagram for the program using Word or other software packages.
    Zip just your class diagram and java files into a single file named prog4.zip. Submit prog4.zip to your
lecture section (which is section 4), Project 4 using web submit.
    Turn in the class diagram and a printout of your source code (.java files) in a folder with your name printed
clearly on the front top right corner.

Sample Interactions:

Please enter the car's make: Chevy
Please enter the car's model: Camaro
Please enter the car's year: 2009
Please enter the car's price: 30000
Please enter the car's term length: 60
Please enter the car's residual value: 5000
Please enter the car's picture URL: http://someSite.com/carPict1.jpg

Please enter the car's make: Chevy
Please enter the car's model: Aveo
Please enter the car's year: 2006
Please enter the car's price: 7555
Please enter the car's term length: 36
Please enter the car's residual value: 1500
Please enter the car's picture URL: http://someSite.com/carPict2.jpg

************************************
************* Car Details **********
************************************
Car make: CHEVY
Car model: CAMARO
Car Year: 2009
Car Price: \$30,000.00
Length of terms: 60.0 months
Residual Value: \$5,000.00
Price with Tax: \$32,175.00
Loan Payment: \$500.72
Lease Payment: \$417.50

************************************

************************************
************* Car Details **********
************************************
Car make: CHEVY
Car model: AVEO
Car Year: 2006
Car Price: \$7,555.00
Length of terms: 36.0 months
Residual Value: \$1,500.00
Price with Tax: \$8,102.74
Loan Payment: \$210.04
Lease Payment: \$168.41

************************************
The Average Loan Payment is \$ 355.38
The Average Lease Payment is \$292.96

BONUS Credits (10%):

Instead of getting the picture URL from the user, consume a Web service from flickr.com to retrieve a picture that is
based on the car attributes.

Some of the Program Grading Criteria:

Design
______ Class diagram
______ Well designed class with proper encapsulation

Source Code
______ Beginning comment block complete
______ Properly indented and commented

Running of Program (must compile without errors)
______ Driver program runs with your file
______ Constructors properly designed
______   Accessors and mutators work correctly
______   Read car info works correctly
______   Computes and reports total price (tax added in)
______   Computes and reports both loan and lease payment correctly
______   Print method output is correct and neatly and clearly labeled
______   Currency is formatted correctly

Others (penalties)
______ Late
______ Files named incorrectly
______ Messy design materials (class diagram)
______ Other problems with program or design

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 2 posted: 5/18/2012 language: pages: 4
fanzhongqing http://