# EMI Calculator in Java

In this tutorial, we will learn how to calculate the EMI in Java. EMI is nothing but, a payable amount that needs to be given to the bank every month until the full amount is paid. It is the summation of the principal amount and Intrest.

The formula to calculate the EMI is:

**EMI=P*r*((1+r)^n/(1+r)^n-1)**

Where P is the Principal amount,r is the rate of interest and n is the number of years.

## EMI Calculator Program in Java

import java.util.*; public class EMICalculator { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter the principle amount"); double p=sc.nextDouble(); System.out.println("Enter the rate of intrest for annum"); double r=sc.nextDouble(); r=r/(12*100); System.out.println("Enter number of months"); int n=sc.nextInt(); double E=p*r*(Math.pow(1+r,n)/(Math.pow(1+r,n)-1)); System.out.print("The EMI is "); System.out.printf("%.2f",E); } }

I have taken inputs from users to initialize the principal amount, rate of interest, and time duration. EMI is paid for every month, so we need to divide the rate of interest by 12.

Here the output looks like this:

Enter the principle amount 10000 Enter the rate of intrest for annum 9 Enter number of months 24 The EMI is 456.85

Also read: Simple Interest Program in Java

## Leave a Reply