0
Plz help I can't find error.
You take a loan from a friend and need to calculate how much you will owe him after 3 months. You are going to pay him back 10% of the remaining loan amount each month. Create a program that takes the loan amount as input, calculates and outputs the remaining amount after 3 months. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double amount = scan.nextInt(); int idk = 0; int months = 3; while (idk < months) { idk++; amount = amount + (amount/10); } system.out.println(amount); } } Also, if possible suggest me any other way of doing this acc to you.
5 Answers
+ 5
Ojas Kanotra
The first problem is System.out.println.
You have system.out.....
Code not recognisiig System
After that, you have some logic issues where it looks like you are adding the interest to the total, instead of subtracting.
But, I think you will be able to sort that out now you can see your output.
Good luck
Let us know if you get stuck
PS:
If you look at your error message, you will see an arrow pointing at the problem
+ 2
Thanks a lot @Rik Wittkopp I will remember your advice. Thanks for helping. Each comment really matters. Thanks.
+ 1
Error code is:
/usercode/Program.java:13: error: package system does not exist
system.out.println(amount);
^
1 error
+ 1
Adding to Rik Wittkop's solution, you might want to use scan.nexrDouble() rather than scan.nextInt() to read value for variable <amount>; considering variable <amount> was of `double` type.