0
credit calculator. what's wrong?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int remainder = 3; for (int i = 1; i <= remainder; i ++) { amount = amount - ((amount/100)*10); i ++; } System.out.println(amount); } }
4 Respostas
+ 2
In you loop, you have i++ twice: Once in the head if the loop, once after calculating the amount. So on everniteration of the loop, i is not only increased by 1, but by 2.
You can remove the i++ after amount.
+ 1
Great that you could solve it! :)
0
Thanks a lot! Problem solved
i++ deleted, i=0
0
Thank you for writing