Question #181765

Design loan calculator using JSP which accepts Periodof Time (in years) and Principal Loan Amount. Display

the

payment amount for each loan and then list the loan

balance and interest paid for each payment over the

term of the

loan for the following time period and interest rate:

a. 1 to 7 year at 5.35%

b. 8 to 15 year at 5.5%

c. 16 to 30 year at 5.75%


Expert's answer

import java.io.*;
  
public class GFG {
      
    // Function to calculate EMI
    static float emi_calculator(float p, 
                           float r, float t)
    {
        float emi;
      
        r = r / (12 * 100); // one month interest
        t = t * 12; // one month period
        emi = (p * r * (float)Math.pow(1 + r, t)) 
                / (float)(Math.pow(1 + r, t) - 1);
      
        return (emi);
    }
      
    // Driver Program
    static public void main (String[] args)
    {
          
        float principal, rate, time, emi;
        principal = 10000;
        rate = 10;
        time = 2;
          
        emi = emi_calculator(principal, rate, time);
          
        System.out.println("Monthly EMI is = " + emi);
    }
}
LATEST TUTORIALS
APPROVED BY CLIENTS