×

Java Programs

Java Practice

EMI Calculator in Java - Java program to calculate EMI

EMI Calculator in Java - This program will read Loan Amount, Interest Rate and Time in Years and calculate monthly EMI.

EMI Calculator Program in Java

//EMI Calculator Program in Java
 
import java.util.*;
 
public class EmiCalc{
 
    public static void main(String []args)
    {
         
        //Scanner class to take user input.
        Scanner X = new Scanner(System.in);
         
        double principal, rate, time, emi;
  
        System.out.print("Enter principal: ");
        principal = X.nextFloat();
      
        System.out.print("Enter rate: ");
        rate = X.nextFloat();
      
        System.out.print("Enter time in year: ");
        time = X.nextFloat();
      
        rate=rate/(12*100); /*one month interest*/
        time=time*12; /*one month period*/
      
      
        emi= (principal*rate*Math.pow(1+rate,time))/(Math.pow(1+rate,time)-1);
      
        System.out.print("Monthly EMI is= "+emi+"\n");
                 
    }
}

Output

    me@linux:~$ javac EmiCalc.java 
    me@linux:~$ java EmiCalc 

    Enter principal: 1000000
    Enter rate: 10.25
    Enter time in year: 10
    Monthly EMI is= 13353.900187677658

Core Java Example Programs »



Related Programs



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.