-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwingCompoundIntrest.java
More file actions
71 lines (56 loc) · 1.41 KB
/
Copy pathSwingCompoundIntrest.java
File metadata and controls
71 lines (56 loc) · 1.41 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
import java.awt.event.*;
import java.util.Scanner;
import javax.swing.*;
public class SwingCompoundIntrest implements ActionListener {
JTextField tf1,tf2,tf3,tf4;
JButton b1;
JLabel l1,l2,l3,l4;
SwingCompoundIntrest(){
JFrame f = new JFrame();
tf1 = new JTextField();
tf1.setBounds(120,50,80,20);
l1 = new JLabel("Principal");
l1.setBounds(30,50,100,20);
tf2 = new JTextField();
tf2.setBounds(120,100,80,20);
l2 = new JLabel("Rate");
l2.setBounds(30,100,100,20);
tf3 = new JTextField();
tf3.setBounds(120,150,80,20);
l3 = new JLabel("Time");
l3.setBounds(30,150,80,20);
tf4 = new JTextField();
tf4.setBounds(120,200,80,20);
l4 = new JLabel("Compound Intrest");
l4.setBounds(30,200,80,20);
b1 = new JButton("calculate");
b1.setBounds(130,250,100,20);
f.add(tf1);
f.add(tf2);
f.add(tf3);
f.add(tf4);
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(b1);
b1.addActionListener(this);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
String s1 = tf1.getText();
String s2 = tf2.getText();
String s3 = tf3.getText();
double pri = Integer.parseInt(s1);
double rate = Integer.parseInt(s2);
double time = Integer.parseInt(s3);
double amt = pri*(Math.pow ((1+ rate*time/100),time) );
String result = String.valueOf(amt);
tf4.setText(result);
}
public static void main (String args[]) {
new SwingCompoundIntrest();
}
}