0

Loan calculator problem

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 for (int x = 1; x <= 6 ; x++){ int payment = amount / 10; amount = amount - payment ; } System.out.println (amount ); } } The result is always up by one. Why is that and how can I fix it?

4th Feb 2021, 4:05 AM
Ozzy Cohen
Ozzy Cohen - avatar
1 Réponse
+ 2
Ozzy Cohen Do this amount = amount - amount * (100 - 90) / 100;
4th Feb 2021, 4:08 AM
A͢J
A͢J - avatar