Create a java application that will extract user input and display as below to c
ID: 3746776 • Letter: C
Question
Create a java application that will extract user input and display as below to calculate a loan payment. Formula is Monthly Payment = loan amount interest rate/1(1+interest rate)^-length of the loan(to the negative power).
Example of output:
Enter the terms of your loan as follows:
(Loan amount; interest rate; number of months)
Example: (25,000; 2.99; 60) or ($25,000; 2.99%; 60)
The terms of your loan are:
Loan amount: $25,000.00
Interest Rate: 2.99%
Months: 60
Your loan payment is $499.11 per month
Explanation / Answer
import java.util.*;
class Loan
{
public static void main (String[] args)
{
System.out.println("Enter the terms of your loan as follows: ");
System.out.println("Loan amount; interest rate; number of months");
Scanner input = new Scanner(System.in);
double loan = input.nextDouble();
double interestRate = input.nextDouble();
int months = input.nextInt();
// interestRate is divided by 12 for monthly interest and divided by 100 for percentage
double payment = (loan*interestRate/1200)/(1-Math.pow(1+interestRate/1200, -months)); ;
System.out.println("The terms of your loan are: ");
System.out.println("Loan amount: $"+loan);
System.out.println("Interest Rate: "+interestRate+"%");
System.out.println("Months: "+months);
System.out.printf("Your loan payment is $%.2f per month",payment);
}
}
Output:
Enter the terms of your loan as follows: 25000 2.99 60
Loan amount; interest rate; number of months
The terms of your loan are:
Loan amount: $25000.0
Interest Rate: 2.99%
Months: 60
Your loan payment is $449.11 per month
Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.