Professional Documents
Culture Documents
20 Mohit
20 Mohit
Roll No:20
Class:MCA(M) 4th Sem
Source Code:-EMI.java
package emi_calculator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class EMI extends JFrame implements ActionListener {
JComboBox type_loan;
JLabel t1,t2,t3;
JTextField txt1,txt2;
JButton b1;
EMI()
{
setLayout(new FlowLayout());
t1=new JLabel("Loan Amount");
txt1=new JTextField(10);
try
{
String ra="";
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(EMI.class.getName()).log(Level.SEVERE, null,
ex);
}
Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:33
06/loan","root","12345");
Statement s=conn.createStatement();
ResultSet rs=s.executeQuery("Select rate from loan
where type='"+rate+"'");
while(rs.next())
{
ra=rs.getString("rate");
}
double p=Double.parseDouble(amount);
double t=Double.parseDouble(time);
double r=Double.parseDouble(ra);
double emi = (p*r*((1 + r)*t))/((1 + r)*t - 1);
JOptionPane.showMessageDialog(null, "EMI="+emi);
}
catch(SQLException e1)
{
e1.printStackTrace();
}
}
Output:-
Database:-
Database name:- loan
Table name:- type_loan