-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeLoanCalculator.java
More file actions
94 lines (81 loc) · 2.04 KB
/
Copy pathHomeLoanCalculator.java
File metadata and controls
94 lines (81 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import java.awt.event.*;
import java.util.Scanner;
import javax.swing.*;
public class HomeLoanCalculator implements ActionListener {
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
JButton b1;
JLabel l1,l2,l3,l4,l5,l6,l7;
HomeLoanCalculator(){
JFrame f = new JFrame();
tf1 = new JTextField();
tf1.setBounds(120,50,80,20);
l1 = new JLabel("Loan Amount");
l1.setBounds(30,50,120,20);
tf2 = new JTextField();
tf2.setBounds(200,100,80,20);
l2 = new JLabel("Tenure (in months)");
l2.setBounds(30,100,250,20);
tf3 = new JTextField();
tf3.setBounds(120,150,80,20);
l3 = new JLabel("Intrest Rate");
l3.setBounds(30,150,120,20);
tf4 = new JTextField();
tf4.setBounds(150,200,80,20);
tf4.setEditable(false);
l4 = new JLabel(" Intrest Amount");
l4.setBounds(30,200,120,20);
tf5 = new JTextField();
tf5.setBounds(150,250,80,20);
tf5.setEditable(false);
l5 = new JLabel("Monthly EMI");
l5.setBounds(30,250,120,20);
tf6 = new JTextField();
tf6.setBounds(150,300,80,20);
tf6.setEditable(false);
l6=new JLabel("Payable");
l6.setBounds(30,300,400,20);
b1 = new JButton("calculate");
b1.setBounds(130,350,100,20);
f.add(tf1);
f.add(tf2);
f.add(tf3);
f.add(tf4);
f.add(tf5);
f.add(tf6);
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(l5);
f.add(l6);
f.add(b1);
b1.addActionListener(this);
f.setSize(500,500);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
String s1 = tf1.getText();
String s2 = tf2.getText();
String s3 = tf3.getText();
double principal= Integer.parseInt(s1);
double rate=Integer.parseInt(s3);
double time=Integer.parseInt(s2);
double intrest =0;
double emi =0;
double amount =0;
double timE = time/12;
amount = principal*(Math.pow((1+rate/100 ),timE));
String payAble = String.format("%.3f",amount);
tf6.setText(payAble);
intrest = amount-principal;
String in = String.format("%.3f",intrest);
tf4.setText(in);
emi = amount/time;
String eMI = String.format("%.3f",emi);
tf5.setText(eMI);
}
public static void main (String args[]) {
new HomeLoanCalculator();
}
}