Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Operation The Data Entry section prompts the user to enter values for the loan amount, yearly interest rate, and number of years. If the user

image text in transcribed

Operation The Data Entry section prompts the user to enter values for the loan amount, yearly interest rate, and number of years. If the user doesnt enter data thats valid, this section displays an appropriate error message and prompts the user again. The Formatted Results section displays a formatted version of the users entries as well as the formatted result of the calculation. The application prompts the user to continue. Save your program as LoanCalculator.java.

Specifications The formula for calculating monthly payment is: double monthlyPayment = loanAmount * monthlyInterestRate/ (1 - 1/Math.pow(1 + monthlyInterestRate, months)); The application should accept decimal entries for the loan amount and interest rate entries. The application should only accept integer values for the years field. The application should only accept integer and decimal values within the following ranges:

Greater Less

Loan amount: 0 1,000,000

yearly interest rate: 0 20

years: 0 100

The application should only accept a value of y or n at the Continue prompt. If the user enters invalid data, the application should display an appropriate error message and prompt the user again until the user enters valid data. The code thats used to validate data should be stored in separate methods. For example: public static double getDoubleWithinRange(Scanner sc, String prompt, double min, double max) public static int getIntWithinRange(Scanner sc, String prompt, int min, int max)

Needed for JAVA

Welcome to the Loan Calculator DATA ENTRY Enter loan amount: ten Error Invalid decimal value Try again Enter loan amount: Error Number must be greater than 0.0 100000000000 Enter loan amount: Error Number must be less than 1000000.0 500000 Enter loan amount: Enter yearly interest rate 5.6 Enter number of years: thirty Error Invalid integer value Try again. Enter number of years: Error Number must be greater than 0 Enter number of years: 100 Error Number must be less than 100 Enter number of years: 30 FORMATTED RESULTS $500,000.00 Loan amount: Yearly interest rate 5.6s Number of years 30 Monthly payment $2,870.39 Continue (y) Error This entry is required Try again. Continue (y) x Error Entry must be 'y' or 'n' Try again Continue (y) n

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions