Rabu, 10 Juni 2015

NETBEANS (TUGAS MODUL 3)

NETBEANS (PEMOGRAMAN VISUAL)

TUGAS MODUL 3

ARITMATIKA

 
HASILNYA


Adapun properties yang harus di atur seperti pada tabel di bawah ini :

Komponen
Properties
Isi
Jlabel
Text
Aritmatika
Jlabel
Text
Bilangan Pertama
Jlabel
Text
Bilangan Kedua
Jlabel
Text
Hasil
Jlabel
Text
Operator
JTextField
Name
Text
eBil1
Kosongkan
JTextField
Name
Text
eBil2
Kosongkan
JTextField
Name
Text
eHasil
Kosongkan
JButton
Name
Text
bTambah
+
JButton
Name
Text
bKurang
-
JButton
Name
Text
bKali
*
JButton
Name
Text
bBagi
/
JButton
Name
Text
bClear
C
JButton
Name
Text
bExit
Exit



Di bawah code berikut :
public class TugasPraktikum3 extends javax.swing.JFrame {
Tambahkan deklarasi variabel sbb:
int a,b,c;
float d,e,f;

Penambahan tersebut agar variabel a s/d f bersifat universal dalam form.
Adapun kode program untuk button Exit sbb:

private void bExitActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
dispose();
}







Adapun kode program untuk button Tambah(+) sbb:
private void bTambahActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
a=Integer.parseInt(eBil1.getText());
b=Integer.parseInt(eBil2.getText());
c=a+b;
eHasil.setText(Integer.toString(c));
}

Adapun kode program untuk button Kurang(-) sbb:
private void bKurangActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
a=Integer.parseInt(eBil1.getText());
b=Integer.parseInt(eBil2.getText());
c=a-b;
eHasil.setText(Integer.toString(c));
}

Adapun kode program untuk button Kali(*) sbb:
private void bKaliActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
d=Float.parseFloat(eBil1.getText());
e=Float.parseFloat(eBil2.getText());
f=d*e;
eHasil.setText(Float.toString(f));
}


Adapun kode program untuk button Bagi(/) sbb:
private void bBagiActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
d=Float.parseFloat(eBil1.getText());
e=Float.parseFloat(eBil2.getText());
f=d/e;
eHasil.setText(Float.toString(f));
}

Adapun kode program untuk button Clear(C) sbb:
private void bClearActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
eBil1.setText("");
eBil2.setText("");
eHasil.setText("");
eBil1.requestFocus();
}

Tidak ada komentar:

Posting Komentar