Calculadora en programacion
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author labsystem
*/
public class funcionalidad {
private String cadena;
private double resultado;
private boolean suma;
private boolean resta;
private boolean multiplicacion;
private boolean division;
private float var1,var2;
public funcionalidad(){
cadena = "";
resta = false;
suma = false;
division = false;
multiplicacion = false;
String S = "";
S.length();
}
public String concatenamiento (String cadena ) {
this.cadena =this.cadena + cadena;
return this.cadena;
}
public voidsuma (String cadena) {
this.resultado = Double.parseDouble(cadena);
suma = true;
this.cadena = "";
}
public void resta (String cadena) {
resta = true;
this.cadena = "";
}
public void multiplicacion (String cadena) {
resta = true;
this.cadena = "";
}
public void division (String cadena) {division = true;
this.cadena = "";
}
public double resultado (String numero) {
if (suma ==true) {
resultado = resultado + Double.parseDouble(numero);
}
else if (resta == true) {
resultado = resultado - Double.parseDouble(numero);
}
else if (multiplicacion == true) {resultado = resultado * Double.parseDouble(numero);
}
else if (division == true) {
resultado = resultado / Double.parseDouble(numero);
}
resta = false;
suma = false;
division = false;
multiplicacion = false;
return resultado;
}
}
RECH NER
/*
* To change thistemplate, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Rechner.java
*
* Created on 28/09/2010, 05:15:26 PM
*/
/**
*
* @author labsystem
*/
public class Rechner extends javax.swing.JFrame {
/** Creates new form Rechner */
funcionalidad obj = new funcionalidad();
public Rechner() {
initComponents();
}
/** Thismethod is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 =new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = newjavax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton15 = new javax.swing.JButton();jButton16 = new javax.swing.JButton();
jButton17 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calculadora"));
jTextField1.setEditable(false);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public...
Regístrate para leer el documento completo.