Question
Java Only!!!!!! Loan Account Class: Create class LoanAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object
Java Only!!!!!!
Loan Account Class:
Create class LoanAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable principal indicating the amount the person is borrowing. Provide method: public double calculateMonthlyPayment(int numberOfPayments) to calculate the monthly payment by using the following formula:
double monthlyPayment = principal * ( monthlyInterest / (1 - Math.pow(1 + monthlyInterest, -numberOfPayments)));
where
monthly interest = annualInterestRate/12.
Provide a static method setAnnualInterestRate that sets the annualInterestRate to a new value. Set the initial loan amount (Principal) for a new loan through the constructor.
Write a program to test class LoanAccount. Instantiate two LoanAccount objects, loan1 and loan2, with principal loan amounts of $5000.00 and $31000.00, respectively. Set annualInterestRate to 1%, then calculate the monthly payment for each loan for 36 months, 60 months, and 72 months and print the monthly payment amounts for both loans. Next, set the annualInterestRate to 5%, and output the same information again. Make sure your dollar amounts are displayed to two decimal places.
Put the code to test the class in the main method of the LoanAccount Class. The output of your program should look like the following:
Java Only!!!!!!!!!!!!!!!
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