Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pbo1a223303;
/**
*
* @author ACER
*/
public class FrmTugas01 extends javax.swing.JFrame {
String bil="";
double jumlah,bil1,bil2;
int pilih;
/**
* Creates new form FrmTugas01
*/
public FrmTugas01() {
initComponents();
}
/**
* 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() {
jLabel1 = new javax.swing.JLabel();
txtlayar = new javax.swing.JTextField();
txt1 = new javax.swing.JButton();
txt2 = new javax.swing.JButton();
txt3 = new javax.swing.JButton();
txt4 = new javax.swing.JButton();
txt5 = new javax.swing.JButton();
txt6 = new javax.swing.JButton();
txt7 = new javax.swing.JButton();
txt8 = new javax.swing.JButton();
txt9 = new javax.swing.JButton();
txtClr = new javax.swing.JButton();
txt0 = new javax.swing.JButton();
txtKoma = new javax.swing.JButton();
txtTambah = new javax.swing.JButton();
txtKurang = new javax.swing.JButton();
txtKali = new javax.swing.JButton();
txtBagi = new javax.swing.JButton();
txtKuadrat = new javax.swing.JButton();
txtPangkat = new javax.swing.JButton();
txtAkar = new javax.swing.JButton();
txtJumlah = new javax.swing.JButton();
txtAkarkubik = new javax.swing.JButton();
txtSin = new javax.swing.JButton();
txtCos = new javax.swing.JButton();
txtTan = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
txt1.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt1.setText("1");
txt1.setPreferredSize(new java.awt.Dimension(60, 60));
txt1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt1ActionPerformed(evt);
}
});
txt2.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt2.setText("2");
txt2.setPreferredSize(new java.awt.Dimension(60, 60));
txt2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt2ActionPerformed(evt);
}
});
txt3.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt3.setText("3");
txt3.setPreferredSize(new java.awt.Dimension(60, 60));
txt3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt3ActionPerformed(evt);
}
});
txt4.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt4.setText("4");
txt4.setPreferredSize(new java.awt.Dimension(60, 60));
txt4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt4ActionPerformed(evt);
}
});
txt5.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt5.setText("5");
txt5.setPreferredSize(new java.awt.Dimension(60, 60));
txt5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt5ActionPerformed(evt);
}
});
txt6.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt6.setText("6");
txt6.setPreferredSize(new java.awt.Dimension(60, 60));
txt6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt6ActionPerformed(evt);
}
});
txt7.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt7.setText("7");
txt7.setPreferredSize(new java.awt.Dimension(60, 60));
txt7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt7ActionPerformed(evt);
}
});
txt8.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt8.setText("9");
txt8.setPreferredSize(new java.awt.Dimension(60, 60));
txt8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt8ActionPerformed(evt);
}
});
txt9.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt9.setText("8");
txt9.setPreferredSize(new java.awt.Dimension(60, 60));
txt9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt9ActionPerformed(evt);
}
});
txtClr.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtClr.setText("c");
txtClr.setPreferredSize(new java.awt.Dimension(60, 60));
txtClr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtClrActionPerformed(evt);
}
});
txt0.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txt0.setText("0");
txt0.setPreferredSize(new java.awt.Dimension(60, 60));
txt0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txt0ActionPerformed(evt);
}
});
txtKoma.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtKoma.setText(".");
txtKoma.setPreferredSize(new java.awt.Dimension(60, 60));
txtKoma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtKomaActionPerformed(evt);
}
});
txtTambah.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtTambah.setText("+");
txtTambah.setPreferredSize(new java.awt.Dimension(60, 60));
txtTambah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTambahActionPerformed(evt);
}
});
txtKurang.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtKurang.setText("-");
txtKurang.setPreferredSize(new java.awt.Dimension(60, 60));
txtKurang.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtKurangActionPerformed(evt);
}
});
txtKali.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtKali.setText("X");
txtKali.setPreferredSize(new java.awt.Dimension(60, 60));
txtKali.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtKaliActionPerformed(evt);
}
});
txtBagi.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtBagi.setText("/");
txtBagi.setPreferredSize(new java.awt.Dimension(60, 60));
txtBagi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtBagiActionPerformed(evt);
}
});
txtKuadrat.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtKuadrat.setText("X²");
txtKuadrat.setPreferredSize(new java.awt.Dimension(60, 60));
txtKuadrat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtKuadratActionPerformed(evt);
}
});
txtPangkat.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtPangkat.setText("Xˆ");
txtPangkat.setPreferredSize(new java.awt.Dimension(60, 60));
txtPangkat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtPangkatActionPerformed(evt);
}
});
txtAkar.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtAkar.setText("√");
txtAkar.setPreferredSize(new java.awt.Dimension(60, 60));
txtAkar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtAkarActionPerformed(evt);
}
});
txtJumlah.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtJumlah.setText("=");
txtJumlah.setPreferredSize(new java.awt.Dimension(60, 60));
txtJumlah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtJumlahActionPerformed(evt);
}
});
txtAkarkubik.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtAkarkubik.setText("³√");
txtAkarkubik.setPreferredSize(new java.awt.Dimension(60, 60));
txtAkarkubik.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtAkarkubikActionPerformed(evt);
}
});
txtSin.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtSin.setText("Sin");
txtSin.setPreferredSize(new java.awt.Dimension(60, 60));
txtSin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtSinActionPerformed(evt);
}
});
txtCos.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtCos.setText("Cos");
txtCos.setPreferredSize(new java.awt.Dimension(60, 60));
txtCos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtCosActionPerformed(evt);
}
});
txtTan.setFont(new java.awt.Font("Calibri", 0, 18)); // NOI18N
txtTan.setText("Tan");
txtTan.setPreferredSize(new java.awt.Dimension(60, 60));
txtTan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtTanActionPerformed(evt);
}
});
jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
jLabel2.setText("SCIENTIFIC CALCULATOR");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtPangkat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtAkar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtAkarkubik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtCos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtClr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtTan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txt7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtBagi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txt0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtKoma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtJumlah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtTambah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txt1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtKurang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(txtKuadrat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtSin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txt6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtKali, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(txtlayar, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(70, 70, 70)))))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(136, 136, 136)
.addComponent(jLabel2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(txtlayar, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtBagi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtAkar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtPangkat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtKali, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtKuadrat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtKurang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtCos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtAkarkubik, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTambah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txt0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtKoma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtJumlah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtTan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtClr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
private void txtJumlahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
switch(pilih){
case 1 :
bil2=Double.parseDouble(String.valueOf(txtlayar.getText()));
jumlah = bil1+bil2;
bil=Double.toString(jumlah);
break;
case 2 :
bil2=Double.parseDouble(String.valueOf(txtlayar.getText()));
jumlah = bil1 - bil2;
bil=Double.toString(jumlah);
break;
case 3 :
bil2=Double.parseDouble(String.valueOf(txtlayar.getText()));
jumlah = bil1 * bil2;
bil=Double.toString(jumlah);
break;
case 4 :
bil2=Double.parseDouble(String.valueOf(txtlayar.getText()));
jumlah = bil1 / bil2;
bil=Double.toString(jumlah);
break;
case 5 :
int y=1,jml;
bil2=Double.parseDouble(bil);
for (jml=1; jml<=bil2; jml++){
y= (int) (bil1 * y);
}
jumlah=y;
bil=Double.toString(jumlah);
break;
case 6:
bil2=Double.parseDouble(bil);
double hasin=Math.toRadians(bil2);
jumlah=Math.sin(bil2);
bil=Double.toString(jumlah);
break;
case 7:
bil2=Double.parseDouble(bil);
double hacos=Math.toRadians(bil2);
jumlah=Math.cos(bil2);
bil=Double.toString(jumlah);
break;
case 8:
bil2=Double.parseDouble(bil);
double hatan=Math.toRadians(bil2);
jumlah=Math.tan(bil2);
bil=Double.toString(jumlah);
break;
}
txtlayar.setText(bil);
}
private void txt1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="1";
txtlayar.setText(bil);
}
private void txt2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="2";
txtlayar.setText(bil);
}
private void txt3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="3";
txtlayar.setText(bil);
}
private void txt4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="4";
txtlayar.setText(bil);
}
private void txt5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="5";
txtlayar.setText(bil);
}
private void txt6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="6";
txtlayar.setText(bil);
}
private void txt7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="7";
txtlayar.setText(bil);
}
private void txt9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="8";
txtlayar.setText(bil);
}
private void txt8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="9";
txtlayar.setText(bil);
}
private void txt0ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +="0";
txtlayar.setText(bil);
}
private void txtTambahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1 = Double.parseDouble(bil);
txtlayar.setText("+");
bil="";
pilih=1;
}
private void txtKurangActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1 = Double.parseDouble(bil);
txtlayar.setText("-");
bil="";
pilih=2;
}
private void txtKaliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1 = Double.parseDouble(bil);
txtlayar.setText("x");
bil="";
pilih=3;
}
private void txtBagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1 = Double.parseDouble(bil);
txtlayar.setText("/");
bil="";
pilih=4;
}
private void txtKomaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil +=".";
txtlayar.setText(bil);
}
private void txtClrActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtlayar.setText(null);
bil1=0.0;
bil2=0.0;
jumlah=0.0;
bil="";
}
private void txtKuadratActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1= Double.parseDouble(bil);
txtlayar.setText("^2");
bil="";
jumlah = bil1 * bil1;
bil=Double.toString(jumlah);
txtlayar.setText(bil);
}
private void txtPangkatActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1=Double.parseDouble(bil);
txtlayar.setText("^");
bil="";
pilih=5;
}
private void txtAkarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1=Double.parseDouble(bil);
txtlayar.setText("√");
bil="";
jumlah=Math.sqrt(bil1);
bil=Double.toString(jumlah);
txtlayar.setText(bil);
}
private void txtAkarkubikActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bil1=Double.parseDouble(bil);
txtlayar.setText("³√");
bil="";
jumlah=Math.cbrt(bil1);
bil=Double.toString(jumlah);
txtlayar.setText(bil);
}
private void txtSinActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtlayar.setText("Sin");
bil="";
pilih=6;
}
private void txtCosActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtlayar.setText("Cos");
bil="";
pilih=7;
}
private void txtTanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtlayar.setText("Tan");
bil="";
pilih=8;
}
/**
* @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(FrmTugas01.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FrmTugas01.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FrmTugas01.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FrmTugas01.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrmTugas01().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JButton txt0;
private javax.swing.JButton txt1;
private javax.swing.JButton txt2;
private javax.swing.JButton txt3;
private javax.swing.JButton txt4;
private javax.swing.JButton txt5;
private javax.swing.JButton txt6;
private javax.swing.JButton txt7;
private javax.swing.JButton txt8;
private javax.swing.JButton txt9;
private javax.swing.JButton txtAkar;
private javax.swing.JButton txtAkarkubik;
private javax.swing.JButton txtBagi;
private javax.swing.JButton txtClr;
private javax.swing.JButton txtCos;
private javax.swing.JButton txtJumlah;
private javax.swing.JButton txtKali;
private javax.swing.JButton txtKoma;
private javax.swing.JButton txtKuadrat;
private javax.swing.JButton txtKurang;
private javax.swing.JButton txtPangkat;
private javax.swing.JButton txtSin;
private javax.swing.JButton txtTambah;
private javax.swing.JButton txtTan;
private javax.swing.JTextField txtlayar;
// End of variables declaration
}
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team