Lab 13 - March 11

 

To receive credit for this lab assignment, you must be finished by Friday, March 14, at 10:00 p.m. (note extended deadline)  After this time you will not receive any credit.

 

Instructions:

1.  Login to UNIX, and write a program to do the following:

DESCRIPTION FROM LAB 12:

Read type of plan for car purchase, it can be A, B or C (String)
Read car price (double). The car price should be at least $77.00
For each one of the payments you should calculate the total price
after adding the interest and the monthly payments.

Plan A: The time to pay the car is one year and the interest is 10%.
Plan B: The time to pay the car is three year and the interest is 25%.
Plan C: The time to pay the car is five year and the interest is 32%.

You must validate that the plan chosen is either A, B or C.
You must validate that the car price is a number (double)
You must validate that the car price is a valid number. This means, no
negative numbers and no price less than $77.


FOR LAB 13, DO THE FOLLOWING:

Do the same car problem from lab 12, but this time, all the calculations should be done in one method. This method should be called by the main method if all the data received is valid.

The purpose is to see that methods help you optimize code so you do not have to cut/paste the same stuff 3 or 4 times in the same program.

Here are 2 possible ways to approach the problem:

public static void carCalculations(double carPrice, int interest, int monthsToPay )(
//this method should print the car price
// total to pay
// monthly payments
}

OR:

You could take this approach:

public static void carCalculations(double carPrice, String plan)(
//this method should print the car price
// total to pay
// monthly payments
}

You may also come up with your own method design. These are just 2 tips.

 

2.  Send an e-mail in Pine and attach your program to the e-mail.  Send to the ics111-lab@hawaii.edu account.  Make sure the subject is 'lab 13'.

3.  Check the webpage to make sure that the e-mail arrived.  Here is the URL:

4.  Once I (TA) get the e-mail in my account AND I can verify it on the web, you will receive your lab participation point.

 

Link to the Java API -  to look up any methods of any class you would like to use.