-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscientific calculator.java
More file actions
233 lines (146 loc) · 5.08 KB
/
scientific calculator.java
File metadata and controls
233 lines (146 loc) · 5.08 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.awt.Color;
import java.awt.Dimension;
public class Hello
{
public static void main(String arc[])
{ JFrame fram=new JFrame("Calculator");
box ob=new box(fram);
ob.buttons(fram);
}
}
class box extends JFrame
{ JPanel contain_buttons=new JPanel();
//...buttons......//
JButton ad=new JButton("+");
JButton minus=new JButton("-");
JButton division=new JButton("\u00F7");
JButton multiplication=new JButton("\u00D7");
JButton root=new JButton("\u221A");
JButton factorial=new JButton("!");
JButton ans=new JButton("ANS");
JButton equal=new JButton("=");
JButton memory=new JButton("M+");
JButton percentage=new JButton("%");
JButton backspace=new JButton("<-");
JButton one=new JButton("1");
JButton two=new JButton("2");
JButton three=new JButton("3");
JButton four=new JButton("4");
JButton five=new JButton("5");
JButton six=new JButton("6");
JButton seven=new JButton("7");
JButton eight=new JButton("8");
JButton nine=new JButton("9");
JButton zero=new JButton("0");
JButton power=new JButton("\u00D7"+"10");
JButton dot=new JButton(".");
JButton ln=new JButton("ln");
JButton cal=new JButton("cal");
JButton clear=new JButton("AC");
JButton sine=new JButton("sin");
JButton cos=new JButton("cos");
JButton tan=new JButton("tan");
JButton bra1=new JButton("(");
JButton bar2=new JButton(")");
JButton pai=new JButton("\u03C0");
JButton e=new JButton("\u212F");
JButton theta=new JButton("\u03B8");
Font font1 = new Font("SansSerif", Font.BOLD, 18);
JTextField jt1=new JTextField(16);
public box(JFrame x)
{
x.setVisible(true);
x.setSize(350,400);
x.setResizable(false);
x.setLayout(new FlowLayout());
x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setExtendedState( Frame.MAXIMIZED_BOTH );
}
public void buttons(JFrame x)
{
int butx=73,buty=36;
jt1.setFont(font1);
contain_buttons.setPreferredSize(new Dimension(330, 333));
contain_buttons.setBackground(Color.CYAN);
jt1.setPreferredSize( new Dimension( 330, 38 ) );
x.add(jt1);
x.add(contain_buttons);
ad.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(ad);
minus.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(minus);
division.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(division);
multiplication.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(multiplication);
root.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(root);
sine.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(sine);
cos.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(cos);
tan.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(tan);
ln.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(ln);
cal.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(cal);
bra1.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(bra1);
bar2.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(bar2);
theta.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(theta);
pai.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(pai);
e.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(e);
factorial.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(factorial);
one.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(one);
two.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(two);
three.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(three);
clear.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(clear);
four.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(four);
five.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(five);
six.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(six);
power.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(power);
seven.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(seven);
eight.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(eight);
nine.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(nine);
memory.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(memory);
zero.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(zero);
dot.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(dot);
ans.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(ans);
equal.setPreferredSize(new Dimension(butx,buty));
contain_buttons.add(equal);
}
private void event_handale()
{
ad.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a1)
{
}
});
}
}