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 .
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...
+ 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);
}
}
+ 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);
+ 1
Yes tried it , it works ... Thanks
0
Your welcome..