+ 1

Loan calculator

How is this wrong? If it gives the output it's asking for? Can't get them 50xp! import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //tu código va aquí System.out.println (amount); int i = 0; for(i = 0 ; i < 3; i++ ) { amount = amount - (amount *10)/100;; System.out.println(amount ); } } }

29th Aug 2021, 12:18 AM
Dario Poddighe
Dario Poddighe - avatar
3 Réponses
+ 4
You need to print the final amount outside loop. Also, it's not necessary to print the input amount. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //tu código va aqu //System.out.println (amount); int i = 0; for(i = 0 ; i < 3; i++ ) { amount = amount - (amount *10)/100; } System.out.println(amount ); } }
29th Aug 2021, 12:41 AM
Simba
Simba - avatar
+ 2
OMG! it worked... Guess it only wanted the final output. That's why I had it inside the loop. And also that's why I printed the amount first. Thanks dude!
29th Aug 2021, 12:55 AM
Dario Poddighe
Dario Poddighe - avatar
31st Aug 2021, 6:31 PM
Изобретатель