0

How do I solve this using loops

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 .

16th Jul 2021, 12:11 PM
Diana Blankson
5 Answers
0
Where is your attempt.. pls try it and post your try.. Using loops is given in lesson. Read again once. You can find it easily...
16th Jul 2021, 12:48 PM
Jayakrishna 🇼🇳
+ 1
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 int month1 = amount * 10/100; int rem1 = amount - month1; int month2 = rem1 * 10/100; int rem2 = rem1 - month2; int month3 = rem2 * 10/100; int rem3 = rem2 - month3; System.out.println(rem3); } }
16th Jul 2021, 1:26 PM
Diana Blankson
+ 1
That works.. You can use loops to do in simple way like: for( int I=0; I <3; I++) amount -= (amount*10/100); System.out.println(amount);
17th Jul 2021, 6:18 PM
Jayakrishna 🇼🇳
+ 1
Yes tried it , it works ... Thanks
18th Jul 2021, 4:26 AM
Diana Blankson
0
Your welcome..
19th Jul 2021, 6:15 PM
Jayakrishna 🇼🇳