0% found this document useful (0 votes)
41 views5 pages

Aplikasi Kalkulator: .Source

This document contains code for a calculator application. The code includes event handlers for buttons 0-9, operators like add, subtract, multiply and divide, clear, and percentage. When a number button is clicked, the number is added to the display. Operator buttons set the operation and clear display. The equals button evaluates the calculation based on the set operation.

Uploaded by

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

Aplikasi Kalkulator: .Source

This document contains code for a calculator application. The code includes event handlers for buttons 0-9, operators like add, subtract, multiply and divide, clear, and percentage. When a number button is clicked, the number is added to the display. Operator buttons set the operation and clear display. The equals button evaluates the calculation based on the set operation.

Uploaded by

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

Aplikasi Kalkulator

>.Source
private void // TODO add your handling code here:
jPanel1AncestorAdded(javax.swing.event.Ances
angka += "4";
torEvent evt) {
Layar.setText(angka);
// TODO add your handling code here:
}
}
private void
btn1ActionPerformed(java.awt.event.ActionEve
nt evt) {
private void
// TODO add your handling code here: btn5ActionPerformed(java.awt.event.ActionEve
nt evt) {
angka += "1";
// TODO add your handling code here:
Layar.setText(angka);
angka += "5";
}
Layar.setText(angka);
private void
btn2ActionPerformed(java.awt.event.ActionEve }
nt evt) {
private void
// TODO add your handling code here: btn6ActionPerformed(java.awt.event.ActionEve
nt evt) {
angka += "2";
// TODO add your handling code here:
Layar.setText(angka);
angka += "6";
}
Layar.setText(angka);
}
private void
btn3ActionPerformed(java.awt.event.ActionEve private void
nt evt) { btn7ActionPerformed(java.awt.event.ActionEve
nt evt) {
// TODO add your handling code here:
// TODO add your handling code here:
angka += "3";
angka += "7";
Layar.setText(angka);
Layar.setText(angka);
}
}

private void
btn4ActionPerformed(java.awt.event.ActionEve
nt evt) {
private void
btn8ActionPerformed(java.awt.event.ActionEve
private void
nt evt) {
btnclearActionPerformed(java.awt.event.Action
// TODO add your handling code here: Event evt) {
angka += "8"; // TODO add your handling code here:
Layar.setText(angka); Layar.setText("");
} angka1=0.0;
angka2=0.0;
private void jumlah=0.0;
btn9ActionPerformed(java.awt.event.ActionEve
angka="";
nt evt) {
}
// TODO add your handling code here:
angka += "9";
private void
Layar.setText(angka);
btntambahActionPerformed(java.awt.event.Acti
} onEvent evt) {
// TODO add your handling code here:
angka1=Double.parseDouble(angka);
Layar.setText("+");
private void angka="";
btntitikActionPerformed(java.awt.event.ActionE
pilih=1;
vent evt) {
}
// TODO add your handling code here:
angka += ".";
Layar.setText(angka);
private void
}
btnkurangActionPerformed(java.awt.event.Actio
nEvent evt) {
private void // TODO add your handling code
btn0ActionPerformed(java.awt.event.ActionEve here:angka1=Double.parseDouble(angka);
nt evt) {
angka1=Double.parseDouble(angka);
// TODO add your handling code here:
Layar.setText("-");
angka += "0";
angka="";
Layar.setText(angka);
pilih=2;
}
} Layar.setText(angka);
break;
private void case 2:
btnkaliActionPerformed(java.awt.event.ActionE
angka2 = Double.parseDouble(angka);
vent evt) {
jumlah = angka1 - angka2;
angka1=Double.parseDouble(angka); //
TODO add your handling code angka = Double.toString(jumlah);
here:angka1=Double.parseDouble(angka);
Layar.setText(angka);
Layar.setText("*");
break;
angka="";
case 3:
pilih=3;
angka2 = Double.parseDouble(angka);
}
jumlah = angka1 * angka2;
angka = Double.toString(jumlah);
private void
btnbagiActionPerformed(java.awt.event.ActionE Layar.setText(angka);
vent evt) { break;
// TODO add your handling code case 4:
here:angka1=Double.parseDouble(angka);
angka2 = Double.parseDouble(angka);
angka1=Double.parseDouble(angka);
jumlah = angka1 / angka2;
Layar.setText("/");
angka = Double.toString(jumlah);
angka="";
Layar.setText(angka);
pilih=4;
break;
}
case 5:
jumlah = angka1 / 100;
private void
jButton1ActionPerformed(java.awt.event.Action angka = Double.toString(jumlah);
Event evt) {
Layar.setText(angka);
// TODO add your handling code here:
break;
switch(pilih){
default:
case 1:
break;
angka2 = Double.parseDouble(angka);
}
jumlah = angka1 + angka2;
}
angka = Double.toString(jumlah);
private void // TODO add your handling code here:
jButton20ActionPerformed(java.awt.event.Actio
angka1=Double.parseDouble(angka);
nEvent evt) {
Layar.setText("%");
// TODO add your handling code here:
angka="";
System.exit(0);
pilih=5;
}
}

private void
btnpersenActionPerformed(java.awt.event.Actio
nEvent evt) {

>. Form_kal.java

Hasil

You might also like