package programmingproject;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Calc extends JFrame implements ActionListener {
JFrame f;
int height=50;
int width=100;
TextField input,nothing;
Button b[]=new Button[17];
String op[]={"DELETE","7","8","9","/","4","5","6",
"x","1","2","3","-"," ","0","=","+"};
int x=0,y=0,ans=0,p,q;
char ch=' ';
Calc()
{
f = new JFrame();
f.setSize(4*width,8*height-19);
f.setLayout(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
input = new TextField("",50);
input.setBounds(0, 0, 4*width, 2*height);
f.add(input);
b[0]=new Button(op[0]);
b[0].setBounds(300, 100, width, height);
b[0].addActionListener(this);
f.add(b[0]);
p=0;
q=3*height;
for(int i=1;i<17;i++)
{
if(op[i].charAt(0) >= '0' && op[i].charAt(0) <= '9' )
{
if(ch == ' ')
x=(x*10)+(Character.getNumericValue(op[i].charAt(0)));
else
y=(y*10)+ (Character.getNumericValue(op[i].charAt(0)));
}
else if(e.getSource() == b[15])
{
ans=operate(ch);
x=ans;
ch=' ';
y=0;
input.setText(Integer.toString(ans));
}
else
{
ch=op[i].charAt(0);
}
}
}
}
public static void main(String[] args) {
new Calc();
}
}