Question
Given the attached files Loan and Test Loan Class you are going to modify the TestLoanClass program to allow the user to enter only an
Given the attached files Loan and Test Loan Class you are going to modify the TestLoanClass program to allow the user to enter only an interest rate of between 2 to 7 percent, years of loan between 5 to 15 years and loan amount is restricted to between $1500 and $25000. You will create a custom exception class, for when the user tries to enter any amount`that is not within those ranges. You will use a try catch block that will check if the amounts enter are within range and if they are not in range tell the user what the problem is and allow the user to enter another number.
import java.util.Scanner; public class TestLoanClass /* Main method public static void main (String[] args) i /Create a Scanner Scanner input = new Scanner (System.in); Enter annual interest rate System.out.print ( "Enter annual interest rate, for example, 3.25:") double annualInterestRate = input.nextDouble(); // Enter number of years System.out.print ("Enter number of years as an integer:") int numberOfYears -input.nextInt ) Enter loan amount System.out.print ("Enter loan amount, for example, 120000.95:") double loanAmount - input.nextDouble ) // Create a Loan object Loan 1ban new Loan (annualInterestRate, numberofYears, loanAmount); // Display loan date, monthly payment, and total payment System.out.printf("The loan was created on %s " + "The monthly payment is %.2f The total payment is2f ", loan.getLoanDate ) toString ), loan.getMonthlyPayment ), loan.getTotalPayment ))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