+ 1

Can anyone help me in java project (Loan Calculator) module2 my code gives correct output in test case 1,2,5 but wrong in 4,5th?

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here int p,rem; for (int i=1;i<7;i++) { p=(amount/10); rem = amount-p; amount = rem ; } System.out.println(amount-1); } }

15th Jan 2021, 4:39 PM
Yashraj Rastogi
Yashraj Rastogi - avatar
1 Answer
+ 1
Yashraj Take amount as double. double amount = scanner.nextDouble(); for(int i = 1; i <= 6; i++) { p = Math.ceil(amount / 10); amout = amount - p; } System.out.println((int) amount);
15th Jan 2021, 5:18 PM
A͢J
A͢J - avatar