0% found this document useful (0 votes)
57 views30 pages

Programming a Calculator

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views30 pages

Programming a Calculator

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

UNIVERSIDAD NACIONAL SAN CRISTÓBAL DE HUAMANGA

FACULTAD DE CIENCIAS AGRARIAS

ESCUELA PROFESIONAL DE INGENIERÍA AGRÍCOLA

VIDEO 1 y 2
CALCULADORA CIENTIFICA

ASIGNATURA: Lenguaje de Programación (LP-281)


SERIE: 200-I
DOCENTE TEORIA: ELOY VILA HUAMAN
DOCENTE PRACTICA: HUBNER JANAMPA PATILLA
ESTUDIANTE: HUAMANI NAJARRO, Gina Flor

AYACUCHO- PERÚ
2023
VIDEO Nº 1

https://www.youtube.com/watch?v=b7rC0BENpQw

APRENDE A CALCULAR TU PRIMERA CALCULADORA PASO A PASO


public class calculadorat extends javax.swing.JFrame {

public float primernumero;

public float segundonumero;

public String operador;

public calculadorat() {

initComponents();

this.setLocationRelativeTo(null);

/**

* This method 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();

casilla = new javax.swing.JLabel();

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 = 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();

jButton15 = new javax.swing.JButton();

jButton16 = new javax.swing.JButton();

jButton17 = new javax.swing.JButton();

jButton18 = new javax.swing.JButton();

jButton19 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(204, 204, 255));

casilla.setBackground(new java.awt.Color(153, 153, 255));

casilla.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

casilla.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102,
102, 255)));
casilla.setOpaque(true);

jButton1.setText("C");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton2.setText("/");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

jButton3.setText("*");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

jButton4.setText("-");

jButton4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

jButton5.setText("8");

jButton5.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {


jButton5ActionPerformed(evt);

});

jButton6.setText("7");

jButton6.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton6ActionPerformed(evt);

});

jButton7.setText("4");

jButton7.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton7ActionPerformed(evt);

});

jButton9.setText("9");

jButton9.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton9ActionPerformed(evt);

});

jButton10.setText("5");

jButton10.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton10ActionPerformed(evt);

});

jButton11.setText("+");
jButton11.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton11ActionPerformed(evt);

});

jButton12.setText("6");

jButton12.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton12ActionPerformed(evt);

});

jButton13.setText("0");

jButton13.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton13ActionPerformed(evt);

});

jButton15.setText("3");

jButton15.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton15ActionPerformed(evt);

});

jButton16.setText("2");

jButton16.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton16ActionPerformed(evt);

});
jButton17.setText("1");

jButton17.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton17ActionPerformed(evt);

});

jButton18.setText("=");

jButton18.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton18ActionPerformed(evt);

});

jButton19.setText(",");

jButton19.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton19ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(casilla, javax.swing.GroupLayout.PREFERRED_SIZE, 240,


javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup()

.addGap(12, 12, 12)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)


.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE,
108, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jButton19, javax.swing.GroupLayout.PREFERRED_SIZE,
45, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGap(18, 18, 18)

.addComponent(jButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(casilla, javax.swing.GroupLayout.PREFERRED_SIZE, 38,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 45,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(jButton18, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

);

pack();

}// </editor-fold>

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

this.primernumero=Float.parseFloat(this.casilla.getText());

this.operador="*";

this.casilla.setText("");
}

private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {

this.segundonumero=Float.parseFloat(this.casilla.getText());

switch(this.operador){

case "+" :this.casilla.setText(sincero(this.primernumero+this.segundonumero));break;

case "-" :this.casilla.setText(sincero(this.primernumero-this.segundonumero));break;

case "*" :this.casilla.setText(sincero(this.primernumero*this.segundonumero));break;

case "/" : if(this.segundonumero==0) {this.casilla.setText("NoSeDivideEntreCero");}

else{

this.casilla.setText(sincero(this.primernumero/this.segundonumero));break;

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"0"); // TODO add your handling code here:

private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"1");

private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"6");

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"9");

private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {


this.casilla.setText(this.casilla.getText()+"2");

private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"3");

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"4");

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"5");

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"7");

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText(this.casilla.getText()+"8");

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

this.casilla.setText("");

private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {

this.primernumero=Float.parseFloat(this.casilla.getText());

this.operador="+";

this.casilla.setText("");

}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

this.primernumero=Float.parseFloat(this.casilla.getText());

this.operador="-";

this.casilla.setText("");

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

this.primernumero=Float.parseFloat(this.casilla.getText());

this.operador="/";

this.casilla.setText("");

private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {

if(!(this.casilla.getText().contains("."))) {

this.casilla.setText(this.casilla.getText()+".");

public String sincero(float resultado){

String retorno= "";

retorno=Float.toString(resultado);

if(resultado%1==0){

retorno=retorno.substring(0, retorno.length()-2);

return retorno;

/**

* @param args the command line arguments

*/
public static void main(String args[]) {

/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

* For details see


http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

*/

try {

for (javax.swing.UIManager.LookAndFeelInfo info :


javax.swing.UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

javax.swing.UIManager.setLookAndFeel(info.getClassName());

break;

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(calculadorat.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(calculadorat.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(calculadorat.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(calculadorat.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {

new calculadorat().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JLabel casilla;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton10;

private javax.swing.JButton jButton11;

private javax.swing.JButton jButton12;

private javax.swing.JButton jButton13;

private javax.swing.JButton jButton15;

private javax.swing.JButton jButton16;

private javax.swing.JButton jButton17;

private javax.swing.JButton jButton18;

private javax.swing.JButton jButton19;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JButton jButton6;

private javax.swing.JButton jButton7;

private javax.swing.JButton jButton9;

private javax.swing.JPanel jPanel1;

// End of variables declaration

EJEMPLO : 85*86=7310
VIDEO 2º
https://www.youtube.com/watch?v=8QQ3sGQRH3M

Calculadora en Java NetBeans | Interfaz Grafica | Mediafire

public class Metodosjava {

private String cadena;

private double resultado;

private boolean suma;


private boolean resta;

private boolean multiplicacion;

private boolean division;

private boolean raiz;

private boolean seno;

private boolean coseno;

private boolean tangente;

private boolean cotangente;

private boolean secante;

private boolean cosecante;

private boolean alcuadrado;

private boolean alapotencia;

public Metodosjava(){

cadena="";

suma=false;

resta=false;

multiplicacion=false;

division=false;

raiz=false;

seno=false;

coseno=false;

tangente=false;

cotangente=false;

secante=false;

cosecante=false;

alcuadrado=false;

alapotencia=false;

public String concatenamiento(String cadena) {


this.cadena=this.cadena+cadena;

return this.cadena;

public void suma (String cadena) {

this.resultado=Double.parseDouble(cadena);

suma=true;

this.cadena="";

public void resta (String cadena) {

this.resultado=Double.parseDouble(cadena);

resta=true;

this.cadena="";

public void multiplicacion (String cadena) {

this.resultado=Double.parseDouble(cadena);

multiplicacion=true;

this.cadena="";

public void division (String cadena) {

this.resultado=Double.parseDouble(cadena);
division=true;

this.cadena="";

public void raiz (String cadena) {

this.resultado=Double.parseDouble(cadena);

raiz=true;

this.cadena="";

public void seno (String cadena) {

this.resultado=Double.parseDouble(cadena);

seno=true;

this.cadena="";

public void coseno (String cadena) {

this.resultado=Double.parseDouble(cadena);

coseno=true;

this.cadena="";

public void tangente (String cadena) {

this.resultado=Double.parseDouble(cadena);

tangente=true;

this.cadena="";
}

public void cotangente (String cadena) {

this.resultado=Double.parseDouble(cadena);

cotangente=true;

this.cadena="";

public void secante (String cadena) {

this.resultado=Double.parseDouble(cadena);

secante=true;

this.cadena="";

public void cosecante (String cadena) {

this.resultado=Double.parseDouble(cadena);

cosecante=true;

this.cadena="";

public void alcuadrado (String cadena) {

this.resultado=Double.parseDouble(cadena);

alcuadrado=true;

this.cadena="";

public void alapotenciacion (String cadena) {


this.resultado=Double.parseDouble(cadena);

alapotencia=true;

this.cadena="";

public void borrar(){

this.resultado=0.0;

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);

}
else if(raiz==true){

resultado=Math.sqrt(Double.parseDouble(numero));

else if(seno==true){

double seno=Math.toRadians(resultado);

resultado=Math.sin(seno);

else if(coseno==true){

double coseno=Math.toRadians(resultado);

resultado=Math.cos(coseno);

else if(tangente==true){

double tangente=Math.toRadians(resultado);

resultado=Math.tan(tangente);

else if(cotangente==true){

double cotangente=Math.toRadians(resultado);

resultado=1/Math.tan(cotangente);

}
else if(secante==true){

double secante=Math.toRadians(resultado);

resultado=1/Math.cos(secante);

else if(cosecante==true){

double cosecante=Math.toRadians(resultado);

resultado=1/Math.sin(cosecante);

else if(alcuadrado==true){

resultado=Math.pow (resultado, 2.0);

else if(alapotencia==true){

resultado=Math.pow (resultado, Double.parseDouble(numero));

suma=false;

resta=false;

multiplicacion=false;

division=false;

raiz=false;

seno=false;

coseno=false;

tangente=false;

cotangente=false;

secante=false;

cosecante=false;

alcuadrado=false;
alapotencia=false;

return resultado;

}
EJEMPLO:1

20^2= 400
EJEMPLO: 2

7563-456=7107

You might also like