+ 1

please tell me where is the mistake? credit calculator

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); } }

4th Jan 2023, 6:49 AM
Nick Vol
Nick Vol - avatar
4 Answers
+ 1
I++, I++; used twise so it's equal to I=I+2 Remove one I++; And if still, not work then use amount*10/100 instead of amount/100*10
4th Jan 2023, 8:13 AM
Jayakrishna 🇼🇳
+ 1
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 = 0; i <= remainder; i++) { amount = amount - (amount*10/100); } System.out.println(amount); } } still showing wrong)))
4th Jan 2023, 8:28 AM
Nick Vol
Nick Vol - avatar
+ 1
You made i = 0 to =3; from 1 so iterate 4 times.
4th Jan 2023, 8:39 AM
Jayakrishna 🇼🇳
+ 1
Thanks a lot! Problem solvedđŸ€đŸ‘
4th Jan 2023, 8:43 AM
Nick Vol
Nick Vol - avatar