Java

Solo disponible en BuenasTareas
  • Páginas : 3 (532 palabras )
  • Descarga(s) : 0
  • Publicado : 6 de marzo de 2011
Leer documento completo
Vista previa del texto
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class calculadora extends Applet implements ActionListener{

private String cadena;
private doubleresultado;
private boolean suma;
private boolean resta;
private boolean multiplicasion;
private boolean divicion;
Buttonb1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18;
TextField t1;
Panel pa1,pa2;

public void init(){
this.setSize(180,200);

}
public calculadora(){

cadena="";
suma=false;resta=false;
multiplicasion=false;
divicion=false;

Panel ac = new Panel();
t1=new TextField("",20);

ac.add(t1);
add( "North",ac);
pa1=new Panel();Panel p1 =new Panel();
p1.setLayout(new GridLayout(5,5,6,6));
p1.add(b1=new Button("9"));
p1.add(b2=new Button("8"));
p1.add(b3=new Button("7"));
p1.add(b4=new Button("6"));p1.add(b5=new Button("5"));
p1.add(b6=new Button("4"));
p1.add(b7=new Button("3"));
p1.add(b8=new Button("2"));
p1.add(b9=new Button("1"));
p1.add(b10=newButton("0"));
p1.add(b11=new Button("."));
p1.add(b12=new Button("="));
p1.add(b13=new Button("+"));
p1.add(b14=new Button("-"));
p1.add(b15=new Button("*"));
p1.add(b16=newButton("/"));
p1.add(b17=new Button("CE"));

add("SOUTH",p1);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);b9.addActionListener(this);
b10.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
b13.addActionListener(this);
b14.addActionListener(this);...
tracking img