Create a Java application that calculates a loan payment based on the following formula:
Payment = Amount of Loan * Interest Rate / (1-(1+Interest Rate)^-Months of loan)
User input must follow the format (amount; rate; months).
Hint: clean user input.
Requirements:
- Obtain the input from the user in "(Loan; rate; months)" format.
- Extract variable values using substring and indexOf methods.
- Clean the loan amount and interest rate and convert them to double types.
- Convert the annual percentage into a monthly ratio (decimal value).
- Accurately calculate the monthly payment using the provided formula.
- The monthly payment does not lose mathematical precision (two decimal points).
- Display the loan terms and monthly payment.
- Format the amount as currency using NumberFormat.
- Format the interest rate as a percent using NumberFormat.
Example of output is below:
Enter the terms of your car purchase in the following format:
(Car Price; Annual Interest Rate; Loan Length in Months)
Example: ($25,000.00; 2.99%; 60)
Example: (25000.00; 2.99; 48)
Example: ($30,000; 1.45%; 60)
Example: (25000.00; 1.49; 36)
---------------------------------
******************************************************************************
Car price (loan amount): $25,000.00
Annual Interest Rate: 1.49%
Loan length in months: 36
---- Your monthly payment is: $710.51 ----
******************************************************************************