Question
Java class Create a program called Loan Amount. This will display how many months it will take to pay off the loan. The program needs
Java class
Create a program called Loan Amount. This will display how many months it will take to pay off the loan.
The program needs the purchase cost, the annual interest rate in percent, and monthly payments.
The monthly interest rate is calculated once and is calculated as interestRate/12.
Suppose you purchased a kitchen appliance that costs $1000. The credit plan on your purchase is: no down payment, an interest rate of 18% per year, which means 1.5% per month, and a monthly payment of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt.
The first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt, which leaves you with the debt of $965.00.
The next month you pay interest of 1.5% of $965.00, which is 14.48. Hence $35.52 (which is $50 - $14.48) are deducted from the amount you owe.
The program must be able to calculate the amount of interest and the size of the debt after each month. This calculation must be a separate method so it can be called separately from the print method below. T
he program must print the data about the loan amount in a table showing the remaining debt and the number of months it will take to pay off the debt. Your program should count the number of months until the debt is not less than the monthly payment, that means the last payment may be less than $50.
To keep the program flexible, the code to calculate the remaining amount of debt must be a separate method so this method can be called from the method which handles printing.
In your program (preferably setters), include reasonability checks on the new value.
For example, if the rate is less than 0, do not change the existing rate to the new value. If doing this validation in setters, be sure to call the setters inside the constructor of class to ensure the validity checks on the new value.
Tester class
Test out the Loan amount class in a tester class that holds a main method.
Do the following using the appropriate constructor and methods:
- Create the loan amount object - Create the Scanner object
- Ask the cost, annual interest rate and monthly payment from the user.
Then execute the toString method to print the table like this:
Enter cost, monthly payment and interest rate
1000
50
18
Loan Amount: $1000.0
Annual Interest Rate, in percent: 18.0%
Monthly Payment: $50.0
Loan Months
--------------------
965.00 1
929.48 2
893.42 3
856.82 4
819.67 5
781.97 6
743.70 7
704.85 8
665.42 9
625.40 10
584.79 11
543.56 12
501.71 13
459.24 14
416.13 15
372.37 16
327.95 17
282.87 18
237.11 19
190.67 20
143.53 21
95.68 22
47.12 23
Check your answers with a calculator and try different values for the loan amount, rate, and monthly installment.
You do not need to use any complicated mathematical formulas; you can solve this problem using simple addition and multiplication.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started