0

How to solve this question by using loops in java?

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. Sample Input: 20000 Sample Output: 10628 Here is the monthly payment schedule: Month 1 Payment: 10% of 20000 = 2000 Remaining amount: 18000 Month 2 Payment: 10% of 18000 = 1800 Remaining amount: 16200 Month 3: Payment: 10% of 16200 = 1620 Remaining amount: 14580 https://code.sololearn.com/cALPu9wF7m1m/?ref=app https://code.sololearn.com/cALPu9wF7m1m/?ref=app

14th Jul 2022, 3:03 AM
Ayush Singh
Ayush Singh - avatar
5 odpowiedzi
+ 2
Ayush Singh Use for loop which will run 3 times and inside for loop do amount = amount - amount / 10;
14th Jul 2022, 3:06 AM
A͢J
A͢J - avatar
+ 2
Ayush Singh Final amount should be print outside.
14th Jul 2022, 3:24 AM
A͢J
A͢J - avatar
+ 2
Ayush Singh Amount ko 1 hi baar print karna hai loop ke bahar. for (int i = 0; i < 3; i++) { amount = amount - amount / 10; } System.out.print(amount);
14th Jul 2022, 3:26 AM
A͢J
A͢J - avatar
+ 1
Thankyou sir. It's working now.
14th Jul 2022, 3:59 AM
Ayush Singh
Ayush Singh - avatar
0
Sir, it's not working. Kya mai galat kr rha hoon https://code.sololearn.com/cq5O9R7X9c8b/?ref=app
14th Jul 2022, 3:20 AM
Ayush Singh
Ayush Singh - avatar