0
How to write the same code using loops?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int x = amount - amount*10/100; int pay2 = x - x*10/100; int pay3 = pay2 - pay2*10/100; System.out.println(pay3); } }
3 Antworten
+ 5
You could use a for-loop like
for (int i = 0; i < 3; i++)
and on each iteration
amount = amount - amount * 10 / 100
+ 1
Please specify a language relevant to your question (Java) in the tags, not '111' ☝
https://code.sololearn.com/W3uiji9X28C1/?ref=app
0
thanks