+ 1

Why some cases still doesn't work?

//Code import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); float rest; rest = (float)amount; for(int r= 0; r<6; r++){ rest -= rest/10 ; } System.out.println((int)rest); } }

19th Dec 2020, 9:59 AM
Saad
Saad - avatar
2 Answers
+ 5
Saad Take amount as double and do for (int i = 0; i < 6; i++) amount = amount - Math.ceil(amount / 10); System.out.println((int) amount);
19th Dec 2020, 11:45 AM
A͢J
A͢J - avatar
0
Done it
21st Dec 2020, 6:20 PM
Saad
Saad - avatar