CMIS 141
Loan program
Write an applet or application to keep track of how much money is owed
after each payment on a loan.
As an example, suppose you start out on day 1 with a loan of $1000 at
an annual percentage rate of 10%, compounded daily. Suppose you make
your first payment of $500 on day 30. The amount you owe after
applying your payment is computed as follows:
- The daily interest rate is 10% / 365 days = 0.0274 % per day
- On day 2, you owe $1000 + ($1000 * 0.0274 %) = $1000.27
- On day 3, you owe $1000.27 + ($1000.27 * 0.0274 %) = $1000.55
- ..
- On day 30, you compute the interest before applying the payment
(of course!). You owe $1007.70 from day 29. Now on day 30 before
the payment, you owe $1007.07 + ($1007.07 * 0.0274 %) = $1007.97.
- Then you apply the payment of $500. You now owe $507.97.
The program will report that after applying the payment on day 30, you
owe $507.97. Notice that the interest compounds daily, which means
each day interest is calculated on that day's balance and added to the
balance (that's how it's done in Ruritania, you got a problem with
that?). Now you could apply another payment on or after day 30, and
the program would tell you how much you owed after that payment. You
can not give a payment on a day before the current payment day.
Your program will input the initial loan amount. It will then ask if
you are a regular customer (R) or a preferred customer (P). Regular
customers get an annual percentage rate (APR) of 10%; preferred
customers get an APR of 8%. This will determine the daily percentage
rate for the duration of the loan.
The program should then accept payments (and indicating the current
balance) until the loan is paid in full, and then report in a
JTextArea:
- How many payments it took to pay the loan
- Total interest that was paid
- Any money returned from the final payment if you overpaid
- Each payment day, amount and resulting balance.
ERROR CHECKING
- Ensure that the initial amount of the loan is positive
- Ensure that user enters preferred or regular customer correctly
- Ensure that each payment amount is positive
- Ensure that the current payment is being applied on or after the day
the last payment was applied
HINTS
- The interest is compounded daily, so calculating one day's interest
and multiplying that by the number of days to the next payment day will
NOT give the correct interest accrued.
Example payment schedule: (note: this 30, 60, 90 is an example
only. The user can make a payment schedule of any number of increasing
payment days and amounts).
Initial loan: $1000
regular customer.
payment #1 of $500 on day 30
On day#30, you owe $507.97.
payment #2 of $500 on day 60
On day#60, you owe $12.17.
payment #3 of $500 on day 90
$487.73 of your final payment will be returned.
You paid off your loan after 90 days in 3 payments.
You paid $12.27 in interest.