Operaciones
package javaapplication;
import javax.swing.JOptionPane;
public class Operaciones {
static double resultado;
static double suma;
public Operaciones(){
resultado = 0;
}
public static double seno(double x){
resultado = Math.sin(x);
return resultado;
}
public static double coseno(double x){
resultado = Math.cos(x);
return resultado;
}
public static double tangente(double x){
resultado = Math.tan(x);
return resultado;
}
public static double raiz(double x){
if(x>=0){
resultado = Math.sqrt(x);
}else{
System.out.println("Solo valores postivos");
resultado = 0;
}
return resultado;
}
public static double logaritmo (double x){
resultado = Math.log(x);
return resultado;
}
public static double suma (double x){
resultado=resultado+x;
return resultado;
}
public static double resta (double x){
resultado = resultado-x;
return resultado;
}
public static double multiplicacion (double x){
resultado = resultado*x;
return resultado;
}
public static double division (double x){
resultado = resultado/x;
return resultado;
}
public static double exponente (double x){
resultado = Math.pow(resultado,x);
return resultado;
}
public static double operadores(double x){
resultado = x;
return resultado;
}
public static double pi(){
resultado = Math.PI;
return resultado;
}
public static double base_exp(double x){
resultado = Math.exp(x);
return resultado;
}
public static double abs(double x){
resultado = Math.abs(x);
return resultado;
}
public static double arcocoseno(double x){
resultado = Math.acos(x);
return resultado;
}
public static double arcoseno(double x){
resultado = Math.asin(x);
return resultado;
}
public static double arcotangente(double x){
resultado = Math.atan(x);
return resultado;
}
public static double cambio_de_signo(double x){
resultado = x*(-1);
return resultado;
}
}
......................................................................
......................................................................
Calculadora
* Calculadora.java
*
* Created on 14-dic-2009, 0:57:18
*/
package javaapplication;
/**
*
* @author Administrador
*/
public class Calculadora extends javax.swing.JApplet {
/** Initializes the applet Calculadora */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
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 = new javax.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();
jButton18 = new javax.swing.JButton();
jButton19 = new javax.swing.JButton();
jButton20 = new javax.swing.JButton();
jButton21 = new javax.swing.JButton();
jButton22 = new javax.swing.JButton();
jButton23 = new javax.swing.JButton();
jButton24 = new javax.swing.JButton();
jButton25 = new javax.swing.JButton();
jButton26 = new javax.swing.JButton();
jButton27 = new javax.swing.JButton();
jButton28 = new javax.swing.JButton();
jButton29 = new javax.swing.JButton();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jButton30 = new javax.swing.JButton();
jLabel1.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N
jLabel1.setText("Calculadora");
jTextField1.setEditable(false);
jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField1.setToolTipText("");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jButton1.setText("Seno");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Coseno");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Tangente");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Potencia");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setText("Logaritmo");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setText("+");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton7.setText("-");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton8.setText("*");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton9.setText("/");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButton10.setText("Raíz");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jButton11.setText("1");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jButton12.setText("0");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jButton13.setText("4");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
jButton14.setText("7");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
jButton15.setText("2");
jButton15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton15ActionPerformed(evt);
}
});
jButton16.setText("5");
jButton16.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton16ActionPerformed(evt);
}
});
jButton17.setText("8");
jButton17.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton17ActionPerformed(evt);
}
});
jButton18.setText("9");
jButton18.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton18ActionPerformed(evt);
}
});
jButton19.setText("6");
jButton19.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton19ActionPerformed(evt);
}
});
jButton20.setText("3");
jButton20.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton20ActionPerformed(evt);
}
});
jButton21.setText(".");
jButton21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton21ActionPerformed(evt);
}
});
jButton22.setText("=");
jButton22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton22ActionPerformed(evt);
}
});
jButton23.setText("BORRAR");
jButton23.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton23ActionPerformed(evt);
}
});
jButton24.setText("PI");
jButton24.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton24ActionPerformed(evt);
}
});
jButton25.setText("exp");
jButton25.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton25ActionPerformed(evt);
}
});
jButton26.setText("absoluto");
jButton26.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton26ActionPerformed(evt);
}
});
jButton27.setText("arcocoseno");
jButton27.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton27ActionPerformed(evt);
}
});
jButton28.setText("arcoseno");
jButton28.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton28ActionPerformed(evt);
}
});
jButton29.setText("arcotangente");
jButton29.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton29ActionPerformed(evt);
}
});
jRadioButton1.setSelected(true);
jRadioButton1.setText("Grados");
jRadioButton1.setAutoscrolls(true);
jRadioButton1.setRequestFocusEnabled(false);
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
jRadioButton2.setText("Radianes");
jRadioButton2.setAutoscrolls(true);
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
jButton30.setText("+/-");
jButton30.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton30ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
.addContainerGap())
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(218, 218, 218)
.addComponent(jLabel1)
.addContainerGap(282, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(46, 46, 46)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton28, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton27, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
.addComponent(jButton29, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton24, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton26, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
.addComponent(jButton25, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
.addGap(30, 30, 30))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jButton30, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton15))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton21))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton16)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton17)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton18)
.addComponent(jButton19)
.addComponent(jButton20)
.addComponent(jButton22)))
.addComponent(jButton23))
.addGap(16, 16, 16))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(jRadioButton1)
.addGap(42, 42, 42)
.addComponent(jRadioButton2)
.addContainerGap(346, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton1)
.addComponent(jRadioButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton6)
.addComponent(jButton5)
.addComponent(jButton7))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jButton23)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton17)
.addComponent(jButton14)
.addComponent(jButton18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton11)
.addComponent(jButton15)
.addComponent(jButton20)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton13)
.addComponent(jButton16)
.addComponent(jButton19)))
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton12)
.addComponent(jButton21)
.addComponent(jButton22)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3)
.addComponent(jButton10)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton9)
.addComponent(jButton8))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton24)
.addComponent(jButton28)
.addComponent(jButton30))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton25)
.addComponent(jButton27))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton29)
.addComponent(jButton26))))
.addContainerGap(52, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(131, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(207, Short.MAX_VALUE))
);
}//
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if( jRadioButton1.isSelected())
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.seno((r*Operaciones.pi())/180);
jTextField1.setText(""+r);
}
else
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.seno(r);
jTextField1.setText(""+r);
}
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r=Operaciones.operadores(r);
aux2="+";
aux="";
jTextField1.setText("");
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r=Operaciones.operadores(r);
aux2="*";
aux="";
jTextField1.setText("");
}
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux = "0";
jTextField1.setText(aux);
}
else{
aux += "0";
jTextField1.setText(aux);
}
}
private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux += ".";
jTextField1.setText(aux);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0"||aux=="")
{
aux="1";
jTextField1.setText(aux);
}
else{
aux += "1";
jTextField1.setText(aux);
}
}
private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "2";
jTextField1.setText(aux);
}
else{
aux += "2";
jTextField1.setText(aux);
}
}
private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "3";
jTextField1.setText(aux);
}
else{
aux += "3";
jTextField1.setText(aux);
}
}
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "4";
jTextField1.setText(aux);
}
else{
aux += "4";
jTextField1.setText(aux);
}
}
private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "5";
jTextField1.setText(aux);
}
else{
aux += "5";
jTextField1.setText(aux);
}
}
private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "6";
jTextField1.setText(aux);
}
else{
aux += "6";
jTextField1.setText(aux);
}
}
private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "7";
jTextField1.setText(aux);
}
else{
aux += "7";
jTextField1.setText(aux);
}
}
private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "8";
jTextField1.setText(aux);
}
else{
aux += "8";
jTextField1.setText(aux);
}
}
private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux=="0")
{
aux= "9";
jTextField1.setText(aux);
}
else{
aux += "9";
jTextField1.setText(aux);
}
}
private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux="0";
jTextField1.setText(aux);
}
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux="0";
jTextField1.setText(aux);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r=Operaciones.operadores(r);
aux2="p";
aux="";
jTextField1.setText("");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if( jRadioButton1.isSelected())
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.coseno((r*Operaciones.pi())/180);
jTextField1.setText(""+r);
}
else
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.coseno(r);
jTextField1.setText(""+r);
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if( jRadioButton1.isSelected())
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.tangente((r*Operaciones.pi())/180);
jTextField1.setText(""+r);
}
else
{
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.tangente(r);
jTextField1.setText(""+r);
}
}
private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(aux2=="+"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.suma(r);
jTextField1.setText(""+r);
}
if(aux2=="-"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.resta(r);
jTextField1.setText(""+r);
}
if(aux2=="*"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.multiplicacion(r);
jTextField1.setText(""+r);
}
if(aux2=="/"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.division(r);
jTextField1.setText(""+r);
}
if(aux2=="p"){
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.exponente(r);
jTextField1.setText(""+r);
}
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r=Operaciones.operadores(r);
aux2="-";
aux="";
jTextField1.setText("");
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r=Operaciones.operadores(r);
aux2="/";
aux="";
jTextField1.setText("");
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.logaritmo(r);
jTextField1.setText(""+r);
}
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.raiz(r);
jTextField1.setText(""+r);
}
private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pi = Operaciones.pi();
jTextField1.setText(""+pi);
}
private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.base_exp(r);
jTextField1.setText(""+r);
}
private void jButton26ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.abs(r);
jTextField1.setText(""+r);
}
private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
double s;
if(r>1||r<-1)
{
jTextField1.setText("ERROR");
}
else{
if( jRadioButton1.isSelected())
{
r = Operaciones.arcocoseno(r);
s= Math.toDegrees(r);
jTextField1.setText(""+s);
}
else
{
r = Operaciones.arcocoseno(r);
jTextField1.setText(""+r);
}
}
}
private void jButton29ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
double s;
if(r>1||r<-1)
{
jTextField1.setText("ERROR");
}
else{
if( jRadioButton1.isSelected())
{
r = Operaciones.arcotangente(r);
s= Math.toDegrees(r);
jTextField1.setText(""+s);
}
else
{
r = Operaciones.arcotangente(r);
jTextField1.setText(""+r);
}
}
}
private void jButton28ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
double s;
if(r>1||r<-1)
{
jTextField1.setText("ERROR");
}
else{
if( jRadioButton1.isSelected())
{
r = Operaciones.arcoseno(r);
s= Math.toDegrees(r);
jTextField1.setText(""+s);
}
else
{
r = Operaciones.arcoseno(r);
jTextField1.setText(""+r);
}
}
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux="0";
jRadioButton1.setSelected(true);
jTextField1.setText(aux);
}
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
aux="0";
buttonGroup1.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
jTextField1.setText(aux);
}
private void jButton30ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String aux1 = jTextField1.getText();
double r = Double.parseDouble(aux1);
r = Operaciones.cambio_de_signo(r);
jTextField1.setText(""+r);
}
public String aux="";
public String aux2="";
public double x;
public double pi;
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
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 jButton14;
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 jButton20;
private javax.swing.JButton jButton21;
private javax.swing.JButton jButton22;
private javax.swing.JButton jButton23;
private javax.swing.JButton jButton24;
private javax.swing.JButton jButton25;
private javax.swing.JButton jButton26;
private javax.swing.JButton jButton27;
private javax.swing.JButton jButton28;
private javax.swing.JButton jButton29;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton30;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
domingo, 13 de diciembre de 2009
Suscribirse a:
Enviar comentarios (Atom)

y el programa no esta subido
ResponderEliminarno veo nada en mi pc
ResponderEliminar