Descargar

Anuncio
ISTP: Manuel Seoane Corrales
Java Swing
CALCULADORA CON JAVA EN NETBEANS public class Calculadora extends javax.swing.JFrame { //variables double masmenos; double primerdouble; double segundouble; double totaldouble; //para los botones int masClic; Lic. Bernardo C. Hermitaño Atencio int menosClic; int divClic; int multiClic; int decimalClic; private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: txtDisplay.setText(""); decimalClic=0; } private void btnUnoActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnUno.getText()); } private void btnDosActionPerformed(java.awt.event.ActionEvent evt) { txtDisplay.setText(txtDisplay.getText()+btnDos.getText()); } private void btnTresActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnTres.getText()); } private void btnCuatroActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnCuatro.getText()); } ISTP: Manuel Seoane Corrales
Java Swing
// TODO add your handling code here: private void btnCincoActionPerformed(java.awt.event.ActionEvent evt) txtDisplay.setText(txtDisplay.getText()+btnCero.getText()); { } // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnCinco.getText()); private void btnPuntoActionPerformed(java.awt.event.ActionEvent evt) } { // TODO add your handling code here: private void btnSeisActionPerformed(java.awt.event.ActionEvent evt) { if(decimalClic==0){ // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnPunto.getText()); txtDisplay.setText(txtDisplay.getText()+btnSeis.getText()); decimalClic=1; } } } private void btnSieteActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: private void btnMasMenosActionPerformed(java.awt.event.ActionEvent evt) { txtDisplay.setText(txtDisplay.getText()+btnSiete.getText()); // TODO add your handling code here: } masmenos=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); masmenos=masmenos*(‐1); private void btnOchoActionPerformed(java.awt.event.ActionEvent evt) txtDisplay.setText(String.valueOf(masmenos)); { } // TODO add your handling code here: txtDisplay.setText(txtDisplay.getText()+btnOcho.getText()); private void btnMasActionPerformed(java.awt.event.ActionEvent evt) { } // TODO add your handling code here: private void btnNueveActionPerformed(java.awt.event.ActionEvent evt) { primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); // TODO add your handling code here: txtDisplay.setText(""); txtDisplay.setText(txtDisplay.getText()+btnNueve.getText()); masClic=1; } decimalClic=0; } private void btnCeroActionPerformed(java.awt.event.ActionEvent evt) { Lic. Bernardo C. Hermitaño Atencio ISTP: Manuel Seoane Corrales
Java Swing
// TODO add your handling code here: private void btnMenosActionPerformed(java.awt.event.ActionEvent evt) { segundouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); // TODO add your handling code here: if(masClic>0){ totaldouble=primerdouble+segundouble; primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); txtDisplay.setText(String.valueOf(totaldouble)); txtDisplay.setText(""); primerdouble=0; menosClic=1; segundouble=0; decimalClic=0; masClic=0; } } if(menosClic>0){ private void btnMultiplicaActionPerformed(java.awt.event.ActionEvent totaldouble=primerdouble‐segundouble; evt) { txtDisplay.setText(String.valueOf(totaldouble)); // TODO add your handling code here: primerdouble=0; primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); segundouble=0; txtDisplay.setText(""); menosClic=0; multiClic=1; } decimalClic=0; if(multiClic>0){ } totaldouble=primerdouble*segundouble; txtDisplay.setText(String.valueOf(totaldouble)); private void btnDivideActionPerformed(java.awt.event.ActionEvent evt) primerdouble=0; segundouble=0; { multiClic=0; // TODO add your handling code here: } if(divClic>0){ primerdouble=(Double.parseDouble(String.valueOf(txtDisplay.getText()))); totaldouble=primerdouble/segundouble; txtDisplay.setText(""); txtDisplay.setText(String.valueOf(totaldouble)); divClic=1; primerdouble=0; decimalClic=0; segundouble=0; } divClic=0; } } private void btnIgualActionPerformed(java.awt.event.ActionEvent evt) { Lic. Bernardo C. Hermitaño Atencio ISTP: Manuel Seoane Corrales
Lic. Bernardo C. Hermitaño Atencio Java Swing
Descargar