Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions