Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java Loan Calculator. Wrote code for a loan calculator but mypayments seem to be calculating too high. ive attached theinstructions given and the code I
Java Loan Calculator. Wrote code for a loan calculator but mypayments seem to be calculating too high. ive attached theinstructions given and the code I wrote. wondering if my monthlypayment and total payment formulas are written correctly? any helpwould be appreciated.
My Code:
public class Assignment2 { public static void main(String[] args){ //Creating the Scanner object Scanner input = new Scanner(System.in); //have user input number of years, rate of interest and loan amount System.out.print("Enter loan term in years: "); int numberOfYears = input.nextInt(); System.out.print("Enter interest rate: "); double monthlyInterestRate = input.nextDouble(); System.out.print("Enter loan amount: "); double loanAmount = input.nextDouble(); //calculate monthly payments double monthlyPayment = ((loanAmount * monthlyInterestRate) / (1 - (1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)))); //display monthly payment details to console System.out.print("Your monthly payment is: "); System.out.println(monthlyPayment); //calculate total payment double totalPayment = (monthlyPayment * numberOfYears * 12); //display monthly total details to console System.out.print("Your total payment is: "); System.out.println(totalPayment); }}
Write a Java Program to create a Software for Loan Payment Program. The program should ask the user to input the Number of Years, Rate of Interest and Amount of Loan in 3 separate lines, and provide the Monthly payment, and Total Payment in 2 separate lines. Calculate the Monthly payment and Total Payment using the following formula: loanAmount X monthlyInterestRate monthlyPayment 1 1 monthlyInterestRate)numberOfYears 12 (1 + totalPayment = monthly Payment X numberOfYears X 12
Step by Step Solution
★★★★★
3.58 Rating (169 Votes )
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