+ 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); } }
4 ответов
+ 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
+ 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)))
+ 1
You made i = 0 to =3; from 1 so iterate 4 times.
+ 1
Thanks a lot! Problem solved🤝👍