+ 3

java loan calculator

cannot find symbol at line 0 ??? I have used amount / 10 cause that's what 10% of amount reduces to. payment = amount / 10; // 10/100 * amount => 1/10 * amount => amount/10 https://code.sololearn.com/cFzy5d41ePle/?ref=app

28th Jan 2021, 10:10 PM
Itz.ME
Itz.ME - avatar
8 Answers
+ 1
Hi! Try with add int in the loop... for(int x=1; x<=6; x++){... /Regards Per B
28th Jan 2021, 10:45 PM
Per Bratthammar
Per Bratthammar - avatar
+ 2
đŸ˜„đŸ˜’
28th Jan 2021, 10:49 PM
Itz.ME
Itz.ME - avatar
+ 1
After fixing the missing "int" you will notice that your result is always a bit above the expected value. This is due to rounding errors. You can take a look at this code to understand it better https://code.sololearn.com/ca5A14A10A15/?ref=app
29th Jan 2021, 2:11 AM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar
+ 1
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
0
Did you do as Per suggested, u forgot the int in your code, int x=1
28th Jan 2021, 11:24 PM
Anastacia Ru
Anastacia Ru - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); // int output=0; int out1=amount; int out; //your code goes here for(int i=0;i<3;i++){ out=(out1/100)*10; out1=out1-out; amount=out1; } System.out.println(amount); } } I did this code, don't know what's wrong
27th Jul 2022, 8:51 AM
Avijit Pal
Avijit Pal - avatar
0
import java.time.Month; import java.util.Scanner; import javax.naming.spi.DirStateFactory.Result; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int loan; int loan2; int loan3; int Month1; int Month2; int Month3; //your code goes here for(int i = 1; i <= 1; i++){ loan = amount * 10/100; Month1 = amount - loan; loan2 = Month1 * 10/100; Month2 = Month1 - loan2; loan3 = Month2 * 10/100; Month3 = Month2 - loan3; System.out.println(Month3); } } }
14th Dec 2022, 1:54 PM
EVAN HUTAGAOL
EVAN HUTAGAOL - avatar