Loan Calculator in Java

 


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

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

*First Try Yourselves

Its a Project
Solution:
import java.util.Scanner;

public class Program
{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int amount = scanner.nextInt();
        int sum1=0;
        int sum2=0;
        int sum3=0;
        sum1=(amount/10);
        int L=amount-sum1;
        sum2=(L/10);
        int M=L-sum2;
        sum3=(M/10);
        int K=M-sum3;
        //System.out.println(L);
        //System.out.println(M);
        System.out.println(K);
    }

}

Thank You.

Post a Comment

Previous Post Next Post