+ 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
4 Respostas
+ 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
+ 7
Thank you so much Piyush. 💐💐💐💐👍👍🍫.
+ 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.
+ 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);
}
}