0

Hi I'm learning Java and I need help with the Loan Calculator

I just finished up to the end of do while loops, however, I can't seem to get the answer to the loan calculator question. You pay 10% of the remainder of the loan each month, for six months. This is my code: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here int month = 0; while (month<6) { double remainder = amount - (0.1*amount); month++; } System.out.println(remainder); } } I've seen other examples use some kind of math ceil thing? But I haven't learned that so is there another way to do it?

6th Dec 2020, 3:19 PM
Jian Zhang
1 Answer
+ 2
Use 90% for 6 months to find the balance. 4 lines of code added. https://code.sololearn.com/cp6GXE4Rc84v/?ref=app If you are paying 10% every month, one way is to find the 10% and then use your total minus the 10% paid to get the balance. The other way, is to find the 90% so you don't have to minus. If you have 100 and you paid 10%, Method 1: 100 - (100 * 10%) = 90 Method 2: 100 * 90% = 90 The "i=0" is used for looping. It will loop from 0 until 5 (< 6), which is 6 times. Finally prints out amount.
6th Dec 2020, 4:15 PM
Lam Wei Li
Lam Wei Li - avatar