Documentos de Académico
Documentos de Profesional
Documentos de Cultura
la parte cientifica
la parte normal
-------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.math.MathContext;
import javax.management.StringValueExp;
import javax.swing.*;
public class ProyectoCalculadora extends JFrame implements
ActionListener
{
String tem="";
String texto="";
float b,c;
double con;
int opcion;
JMenuBar contenedor;
JMenu ver,edicion,ayuda ;
JRadioButtonMenuItem radianes,centimetros;
JMenuItem
estandar,cientifica,programador,copiar,pegar,historial,ver_ayuda,acerc
a_calculadora;
JButton jButton1=new JButton("gsm");
JButton jButton2=new JButton("exp");
JButton jButton3=new JButton("ln");
JButton jButton4=new JButton("sin");
JButton jButton5=new JButton("x^y");
JButton jButton6=new JButton("log");
JButton jButton7=new JButton("cos");
JButton jButton8=new JButton("x^3");
JButton jButton9=new JButton("n!");
JButton jButton10=new JButton("tan");
JButton jButton11=new JButton("x^2");
JButton jButton12=new JButton("1/x");
JButton jButton13=new JButton("7");
JButton jButton14=new JButton("8");
JButton jButton15=new JButton("9");
JButton jButton16=new JButton("/");
JButton jButton17=new JButton("4");
JButton jButton18=new JButton("5");
JButton jButton19=new JButton("6");
JButton jButton20=new JButton("*");
JButton jButton21=new JButton("1");
JButton jButton22=new JButton("2");
JButton jButton23=new JButton("3");
JButton jButton24=new JButton("-");
JButton jButton25=new JButton("0");
JButton jButton26=new JButton("+/-");
JButton jButton27=new JButton(",");
JButton jButton28=new JButton("+");
JButton jButton29=new JButton("=");
JButton jButton30=new JButton("Retroceso");
JButton jButton31=new JButton("CE");
JButton jButton32=new JButton("C");
JButton jButton33=new JButton("sq");
JButton jButton34=new JButton("%");
JButton jButton35=new JButton(".");
jButton30.setBounds(260,95,93,25);
jButton31.setBounds(356,95,50,25);
jButton32.setBounds(409,95,44,25);
//button numericos
jButton13.setBounds(260,125,45,25);
jButton14.setBounds(310,125,45,25);
jButton15.setBounds(360,125,45,25);
jButton16.setBounds(410,125,45,25);
jButton17.setBounds(260,155,45,25);
jButton18.setBounds(310,155,45,25);
jButton19.setBounds(360,155,45,25);
jButton20.setBounds(410,155,45,25);
jButton21.setBounds(260,185,45,25);
jButton22.setBounds(310,185,45,25);
jButton23.setBounds(360,185,45,25);
jButton24.setBounds(410,185,45,25);
jButton25.setBounds(260,215,45,25);
jButton26.setBounds(308,215,50,25);
jButton27.setBounds(360,215,45,25);
jButton28.setBounds(410,215,45,25);
jButton29.setBounds(410,245,42,25);
this.getContentPane().add(jTextField1);
this.getContentPane().add(radianes);
this.getContentPane().add(centimetros);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.getContentPane().add(jButton3);
this.getContentPane().add(jButton4);
this.getContentPane().add(jButton5);
this.getContentPane().add(jButton6);
this.getContentPane().add(jButton7);
this.getContentPane().add(jButton8);
this.getContentPane().add(jButton9);
this.getContentPane().add(jButton10);
this.getContentPane().add(jButton11);
this.getContentPane().add(jButton12);
this.getContentPane().add(jButton13);
this.getContentPane().add(jButton14);
this.getContentPane().add(jButton15);
this.getContentPane().add(jButton16);
this.getContentPane().add(jButton17);
this.getContentPane().add(jButton18);
this.getContentPane().add(jButton19);
this.getContentPane().add(jButton20);
this.getContentPane().add(jButton21);
this.getContentPane().add(jButton22);
this.getContentPane().add(jButton23);
this.getContentPane().add(jButton24);
this.getContentPane().add(jButton25);
this.getContentPane().add(jButton26);
this.getContentPane().add(jButton27);
this.getContentPane().add(jButton28);
this.getContentPane().add(jButton29);
this.getContentPane().add(jButton30);
this.getContentPane().add(jButton31);
this.getContentPane().add(jButton32);
this.getContentPane().add(jButton33);
this.getContentPane().add(jButton34);
this.getContentPane().add(jButton35);
//poniendo al evento
jButton1.addActionListener(this);
jButton2.addActionListener(this);
jButton3.addActionListener(this);
jButton4.addActionListener(this);
jButton5.addActionListener(this);
jButton6.addActionListener(this);
jButton7.addActionListener(this);
jButton8.addActionListener(this);
jButton9.addActionListener(this);
jButton10.addActionListener(this);
jButton11.addActionListener(this);
jButton12.addActionListener(this);
jButton13.addActionListener(this);
jButton14.addActionListener(this);
jButton15.addActionListener(this);
jButton16.addActionListener(this);
jButton17.addActionListener(this);
jButton18.addActionListener(this);
jButton19.addActionListener(this);
jButton20.addActionListener(this);
jButton21.addActionListener(this);
jButton22.addActionListener(this);
jButton23.addActionListener(this);
jButton24.addActionListener(this);
jButton25.addActionListener(this);
jButton26.addActionListener(this);
jButton27.addActionListener(this);
jButton28.addActionListener(this);
jButton29.addActionListener(this);
jButton30.addActionListener(this);
jButton31.addActionListener(this);
jButton32.addActionListener(this);
jButton33.addActionListener(this);
jButton35.addActionListener(this);
ver_ayuda.addActionListener(this);
//para los menus
cientifica.addActionListener(this);
estandar.addActionListener(this);
copiar.addActionListener(this);
pegar.addActionListener(this);
this.setBounds(500,100,475,335);
this.setResizable(isMaximumSizeSet());//desactiva opcion
maximizar
this.getContentPane().setBackground(Color.LIGHT_GRAY);
this.setLayout(null);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args)
{
new ProyectoCalculadora("Calculadora");
}
// iniciar implements ActionListener para los eventos
jTextField1.setText(String.valueOf(Math.log(b)));//ln
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton4)
{
b=Float.parseFloat(jTextField1.getText());
con=(b*Math.PI)/180;//convercion de radianes a
sexagesimales
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.sin(con)));
c=0;
con=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton5)
{
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
opcion=5;
tem="";
}
if(e.getSource()==ProyectoCalculadora.this.jButton6)
{
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.log10(b)));
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton7)
{
b=Float.parseFloat(jTextField1.getText());
con=(b*Math.PI)/180;
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.cos(con)));
con=0;
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton8)
{
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.pow(b,3)));
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton9)//factorial
{ double k=1;
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
for (int i = 1; i <=b; i++)
{
k=k*i;
}
jTextField1.setText(String.valueOf(k));
}
if(e.getSource()==ProyectoCalculadora.this.jButton10)
{
b=Float.parseFloat(jTextField1.getText());
con=(b*Math.PI)/180;//convercion de grados a
radianes
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.tan(con)));
con=0;
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton11)
{
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
jTextField1.setText(String.valueOf(Math.pow(b,2)));
c=0;
}
if(e.getSource()==ProyectoCalculadora.this.jButton12)
{
b=Float.parseFloat(jTextField1.getText());
jTextField1.setText("");
if(b!=0)
jTextField1.setText(String.valueOf(1/b));
else