Question
Hi, im trying to write a simple loan calculator that prints each months balance, intrest, and payment. Here is the code i have so far,
Hi, im trying to write a simple loan calculator that prints each months balance, intrest, and payment. Here is the code i have so far, but for some reason it counts up and not down and i have to add a roundToPenny method.
public static void main(String[] args) { double carLoan = 105; int loanLength = 5; double monthlyPayment = 20; double monthlyBalance = 0; double remainingBalance = 0; double interestRate = .05; double interest;
while (monthlyBalance <= carLoan ) { monthlyBalance = carLoan - monthlyPayment; interest = monthlyBalance * interestRate; monthlyPayment = monthlyPayment + interest; loanLength --; System.out.println("Interest " + interest); System.out.println("MontlyPayment " + monthlyPayment); System.out.println("MonthlyBalance " + monthlyBalance); System.out.println(" month " + loanLength); } }
Step by Step Solution
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