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

20th Nov 2021, 7:23 PM
Osovik Kostyantin
3 Answers
+ 5
You could use a for-loop like for (int i = 0; i < 3; i++) and on each iteration amount = amount - amount * 10 / 100
20th Nov 2021, 7:44 PM
Lisa
Lisa - avatar
+ 1
Please specify a language relevant to your question (Java) in the tags, not '111' ☝ https://code.sololearn.com/W3uiji9X28C1/?ref=app
21st Nov 2021, 12:59 AM
Ipang
0
thanks
24th Nov 2021, 6:26 PM
Osovik Kostyantin