import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Frame1 extends JFrame
{
JTextField t1=new JTextField();
JButton b1=new JButton("0");
JButton b2=new JButton("1");
JButton b3=new JButton("2");
JButton b4=new JButton("3");
JButton b5=new JButton("4");
JButton b6=new JButton("5");
JButton b7=new JButton("6");
JButton b8=new JButton("7");
JButton b9=new JButton("8");
JButton b10=new JButton("9");
JButton b11=new JButton("+");
JButton b12=new JButton("-");
JButton b13=new JButton("X");
JButton b14=new JButton("/");
JButton b15=new JButton("=");
JButton b16=new JButton("AC");
JButton b17=new JButton(".");
JButton b18=new JButton("X\u00B2");
JButton b19=new JButton("X\u00B3");
JButton b20=new JButton("log");
JButton b21=new JButton("sin");
JButton b22=new JButton("cos");
JButton b23=new JButton("tan");
JButton b24=new JButton("ceil");
JButton b25=new JButton("floor");
JButton b26=new JButton("rint");
JButton b27=new JButton("abs");
JButton b28=new JButton("max");
JButton b29=new JButton("min");
JButton b30=new JButton("\u221Ax");
JButton b31=new JButton("\u221Bx");
JButton b32=new JButton("1/x");
JButton b33=new JButton("ON");
JButton b34=new JButton("00");
JButton b35=new JButton("BIN");
Frame1()
{
setSize(450,600);
setDefaultCloseOperation(3);
setLayout(null);
t1.setBounds(20,20,400,60);add(t1);
t1.setBackground(new Color(255,255,255));
t1.setFont(new Font("Arial",1,24));
t1.setEditable(false);
t1.setHorizontalAlignment(4);
b1.setBounds(20,90,50,50);add(b1);
b2.setBounds(80,90,50,50);add(b2);
b3.setBounds(140,90,50,50);add(b3);
b4.setBounds(200,90,50,50);add(b4);
b5.setBounds(260,90,50,50);add(b5);
b6.setBounds(20,150,50,50);add(b6);
b7.setBounds(80,150,50,50);add(b7);
b8.setBounds(140,150,50,50);add(b8);
b9.setBounds(200,150,50,50);add(b9);
b10.setBounds(260,150,50,50);add(b10);
b11.setBounds(20,210,50,50);add(b11);
b12.setBounds(80,210,50,50);add(b12);
b13.setBounds(140,210,50,50);add(b13);
b14.setBounds(200,210,50,50);add(b14);
b15.setBounds(260,210,50,50);add(b15);
b16.setBounds(320,90,70,50);add(b16);
b17.setBounds(20,270,50,50);add(b17);
b18.setBounds(80,270,50,50);add(b18);
b17.setFont(new Font("Arial",1,30));
b19.setBounds(140,270,50,50);add(b19);
b20.setBounds(200,270,90,50);add(b20);
b21.setBounds(320,150,70,50);add(b21);
b22.setBounds(320,210,70,50);add(b22);
b23.setBounds(305,270,85,50);add(b23);
b24.setBounds(20,330,65,50);add(b24);
b25.setBounds(95,330,65,50);add(b25);
b26.setBounds(170,330,65,50);add(b26);
b27.setBounds(245,330,65,50);add(b27);
b28.setBounds(20,390,65,50);add(b28);
b29.setBounds(95,390,65,50);add(b29);
b30.setBounds(170,390,65,50);add(b30);
b31.setBounds(245,390,65,50);add(b31);
b32.setBounds(320,330,65,50);add(b32);
b33.setBounds(320,390,65,50);add(b33);
b34.setBounds(20,450,65,50);add(b34);
b35.setBounds(95,450,70,50);add(b35);
Font ff=new Font("arial",1,25);
b1.setFont(ff);
b2.setFont(ff);
b3.setFont(ff);
b4.setFont(ff);
b5.setFont(ff);
b6.setFont(ff);
b7.setFont(ff);
b8.setFont(ff);
b9.setFont(ff);
b10.setFont(ff);
b11.setFont(ff);
b12.setFont(ff);
b13.setFont(new Font("arial",1,15));
b14.setFont(ff);
b15.setFont(ff);
b18.setFont(new Font("arial",1,15));
b19.setFont(new Font("arial",1,15));
b30.setFont(new Font("arial",1,15));
b34.setFont(ff);
b21.setFont(new Font("arial",1,20));
b22.setFont(new Font("arial",1,20));
b23.setFont(new Font("arial",1,20));
b16.setFont(new Font("arial",1,20));
b24.setFont(new Font("arial",1,15));
b25.setFont(new Font("arial",1,12));
b26.setFont(new Font("arial",1,15));
b27.setFont(new Font("arial",1,15));
b28.setFont(new Font("arial",1,15));
b29.setFont(new Font("arial",1,15));
b33.setFont(new Font("arial",1,20));
b35.setFont(new Font("arial",1,20));
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b3.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b4.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b5.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b6.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b7.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b8.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b9.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b10.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b11.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b12.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b13.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b14.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b15.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f2(e);
}
});
b16.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f3(e);
}
});
b17.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f1(e);
}
});
b18.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f4(e);
}
});
b19.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f5(e);
}
});
b20.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f6(e);
}
});
b21.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f7(e);
}
});
b22.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f8(e);
}
});
b23.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f9(e);
}
});
b24.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f10(e);
}
});
b25.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f11(e);
}
});
b26.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f12(e);
}
});
b27.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f13(e);
}
});
b28.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f14(e);
}
});
b29.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f15(e);
}
});
b30.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f16(e);
}
});
b31.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f17(e);
}
});
b32.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f18(e);
}
});
b33.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f19(e);
}
});
b34.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
f20(e);
}
});
}
void f1(ActionEvent e)
{
String s1=t1.getText();
String s2=e.getActionCommand();
t1.setText(s1+s2);
}
void f2(ActionEvent e)
{
String s=t1.getText();
int p=s.indexOf("+");
if(p>0)
{
String s1=s.substring(0,p);
String s2=s.substring(p+1);
double x=Double.parseDouble(s1);
double y=Double.parseDouble(s2);
double z=x+y;
t1.setText(z+"");
}
int p1=s.indexOf("-");
if(p1>0)
{
String s1=s.substring(0,p1);
String s2=s.substring(p1+1);
double x1=Double.parseDouble(s1);
double y1=Double.parseDouble(s2);
double z1=x1-y1;
t1.setText(z1+"");
}
int p2=s.indexOf("X");
if(p2>0)
{
String s1=s.substring(0,p2);
String s2=s.substring(p2+1);
double x2=Double.parseDouble(s1);
double y2=Double.parseDouble(s2);
double z2=x2*y2;
t1.setText(z2+"");
}
int p3=s.indexOf("/");
if(p3>0)
{
String s1=s.substring(0,p3);
String s2=s.substring(p3+1);
double x3=Double.parseDouble(s1);
double y3=Double.parseDouble(s2);
double z3=x3/y3;
t1.setText(z3+"");
}
}
void f3(ActionEvent e)
{
t1.setText(" ");
}
void f4(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.pow(x1,2);
t1.setText(x5+"");
}
void f5(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.pow(x1,3);
t1.setText(x5+"");
}
void f6(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.log10(x1);
t1.setText(x5+"");
}
void f7(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double a=Math.toRadians(x1);
double x5=Math.sin(a);
t1.setText(x5+"");
}
void f8(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double a=Math.toRadians(x1);
double x5=Math.cos(a);
t1.setText(x5+"");
}
void f9(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double a=Math.toRadians(x1);
double x5=Math.tan(a);
t1.setText(x5+"");
}
void f10(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.ceil(x1);
t1.setText(x5+"");
}
void f11(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.floor(x1);
t1.setText(x5+"");
}
void f12(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.rint(x1);
t1.setText(x5+"");
}
void f13(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.abs(x1);
t1.setText(x5+"");
}
void f14(ActionEvent e)
{
String s1=t1.getText();
String s2=e.getActionCommand();
double x1=Double.parseDouble(s1);
double x2=Double.parseDouble(s2);
double x5=Math.max(x1,x2);
t1.setText(x5+"");
}
void f15(ActionEvent e)
{
String s1=t1.getText();
String s2=e.getActionCommand();
double x1=Double.parseDouble(s1);
double x2=Double.parseDouble(s2);
double x5=Math.min(x1,x2);
t1.setText(x5+"");
}
void f16(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.sqrt(x1);
t1.setText(x5+"");
}
void f17(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=Math.cbrt(x1);
t1.setText(x5+"");
}
void f18(ActionEvent e)
{
String s1=t1.getText();
double x1=Double.parseDouble(s1);
double x5=(1/x1);
t1.setText(x5+"");
}
void f19(ActionEvent e)
{
t1.setText(0+"");
}
void f20(ActionEvent e)
{
String s1=t1.getText();
String s2=e.getActionCommand();
t1.setText(s1+s2);
}
}
class SimpleAirthmaticCalculator
{
public static void main(String[] aa)
{
Frame1 f=new Frame1();
f.setVisible(true);
}
}