+ 2

Loan calculator JAVA CODE PROJECT 2.

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 count = 0; double percentage = 0.1; while(count < 3){ int payment = (int) percentage * amount; amount = amount - payment; if(count == 2){ System.out.println(amount); break; } count++; } } } // I have try my best but nothing is coming up.

26th Nov 2022, 6:27 PM
Uchenna Bethel Orji
Uchenna Bethel Orji - avatar
2 Answers
+ 4
This line result as: int payment = (int) percentage * amount; = (int) 0.1 * amount = 0*amount= 0 Instead use int payment =(int) (amount * 0.1) ;
26th Nov 2022, 6:47 PM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Wow, thanks man
26th Nov 2022, 6:50 PM
Uchenna Bethel Orji
Uchenna Bethel Orji - avatar