0
What am i doing wrong?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int remain=amount; int months = 1; for(months=1; months<=6; months++){ int paid = (remain/10); remain=remain-paid; System.out.println(remain); } } }
2 ответов
0
The output got 5 correct results and the 6th instead is 1 greater ...for example instead of 53144 i get 53145 as 6th result!
0
You should get fraction part in remain/10 and round up value.
For if : remain/10.0 = 12.1 then use 13 value.