Need help for Sololearn's Java "Loan Calculator" practice please... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Need help for Sololearn's Java "Loan Calculator" practice please...

Hi! I'm newbie here 😄... How do i get the final payment of 6th month with the value of 53144 when the user input is 100000? As I got mine with the value of 53145 for 6th month payment. (sorry for my bad english 😅). Thanks! Here is my code: 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 System.out.println("Here is the monthly payment schedule:"); for(int x=1;x<=6;x++){ System.out.println("Month "+x); System.out.println("Payment: 10% of "+amount+" = "+amount); amount=amount-(amount*10/100); System.out.println("Remaining Amount: "+amount); } } }

13th Mar 2021, 9:45 AM
Naslyda
Naslyda - avatar
3 Answers
+ 3
for(int month = 0;month < 6;month++) amount = amount * 90 / 100; System.out.println(amount); It will be more easier if you take 90 instead of 10
13th Mar 2021, 9:50 AM
Sharique Khan
Sharique Khan - avatar
+ 2
Your Welcome Naslyda
13th Mar 2021, 1:04 PM
Sharique Khan
Sharique Khan - avatar
0
Sharique Khan thank you for your answer! It's working now!
13th Mar 2021, 1:03 PM
Naslyda
Naslyda - avatar