+ 2

# Loan Calculator

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: 14580 https://code.sololearn.com/cs3nA4YT5vU0/?ref=app

7 ответов

+ 3

int amount =scanner.nextInt();
for(int x=1; x<=3; x++)
amount -= amount/10; //take 10.0 for precision value to include.
System.out.println(amount);

+ 4

What is Your question actually ?

+ 2

Yes. I know this but what is your problem with the code or doubt or your question?

+ 1

For example :
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

+ 1

Can u code this using ‘for’ loop instead of ‘while’?

+ 1

👏👏👏 Nice bro Jayakrishna 🇮🇳

+ 1

🙏