Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions