Simple recursive Java language thanks
Chapter 11 Projects 1. I after 11.5-easy] Loan Payments and Balances Write a program that determines the level payment amount, paymentAmount, needed to pay off a loan of loanAmount in a number of installments equal to numberOf Payments. Assume that the interest rate is given by rate. Do not use any arrays. Use recursion. The recurrence relation is: rate) paymentAmount balance (k) balance (k-1)(1.0 k is the payment number when k = O. balance - loan Amount where: and: The final payment occurs when k payment: numberof Payments, and immediately after that final balance (numberofPayments)0.0o. This final zero balance should be your recursive starting condition Since paymentAmount is initially unknown, balance (k-1 ) is also unknown, and if you were doing a hand evaluation, these would both be unknowns during the calling sequence. But you can "normalize" the problem by initially assuming that paymentAmount 1.00. Then you can re-arrange the recurrence relation like this: balance (k-1) paymentAmount) / (1.0 rate) (balance (k) + + = Using this latter relation during the calling sequence, work back in time to determine the amount of the loan that could be paid off with k equal payments of 1.00. Then, at the stopping condition, scale up the paymentAmount by the same as you need to scale up the balance to equal the specified 1oanAmount. At the stopping condition, print the value of this scaled up paymentAmount. This is the desired answer. But it's also nice to know what the current balance is as a loan is being paid off. It's easy to display this information during the return sequence, using the original recurrence relation. Assuming a S5,000 loan, 5% interest rate, and 10 payments, here's the output your program should display: Enter loan amount, rate, and number of payments: 5000.00 0.05 10 paymentAmount= 647.52 payment# 0, balance 5000.00 payment# 1, balance-4602.48 payment# 2, balance 4185.08 payment # 3, balance. 3746.81 payment# 4, balance= 3286.63 payment# 5, balance. 2803.44 payment# 6, balance,: 2296.08 payment# 7, balance. 1763.37 payment # 8, balance-1204.01 payment # 9, balance. 616.69 payment# 10, balance 0.00