+ 14

Loan Calculator problem in java. What is the error in my code?

It passes 3 out of 5 test cases.Please help me. https://code.sololearn.com/c5wzkwW4Iwq3/?ref=app

27th Nov 2020, 12:16 AM
Mohammed Qadir Khan
4 ответов
+ 14
Use math.ceil method and u have to convert it to int datatype also Like this remain=(int)Math.ceil(percent*amount); Happy coding
27th Nov 2020, 12:50 AM
Piyush
Piyush - avatar
+ 7
Thank you so much Piyush. 💐💐💐💐👍👍🍫.
27th Nov 2020, 1:59 AM
Mohammed Qadir Khan
+ 7
Use 90% for 6 months to find the balance. 4 lines of code added. https://code.sololearn.com/cp6GXE4Rc84v/?ref=app If you are paying 10% every month, one way is to find the 10% and then use your total minus the 10% paid to get the balance. The other way, is to find the 90% so you don't have to minus. If you have 100 and you paid 10%, Method 1: 100 - (100 * 10%) = 90 Method 2: 100 * 90% = 90 The "i=0" is used for looping. It will loop from 0 until 5 (< 6), which is 6 times. Finally prints out amount.
30th Nov 2020, 5:59 PM
Lam Wei Li
Lam Wei Li - avatar
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int loan; //your code goes here for(int i=1;i<=3;i++) { loan =amount/10; amount-=loan; } System.out.println(amount); } }
14th Jun 2021, 9:18 AM
Dharmi Sri
Dharmi Sri - avatar