Npm : 15110813
Kelas : 3KA33
ANALISA LESIKAL PROGRAM KALKULATOR SEDERHANA DENGAN MENGUNAKAN JAVA
Bentuk Koding :
package calculate;
public class KalkulatorSederhana extends javax.swing.JFrame {
public KalkulatorSederhana() {
initComponents();
}
private void btntambahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 + input2;
this.lbhasil.setText(""+hasil);
}
private void btnkurangActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 - input2;
this.lbhasil.setText(""+hasil);
}
private void btnkaliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 * input2;
this.lbhasil.setText(""+hasil);
}
private void btnbagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 / input2;
this.lbhasil.setText(""+hasil);
}
public static void main(String args[]) {
public class KalkulatorSederhana extends javax.swing.JFrame {
public KalkulatorSederhana() {
initComponents();
}
private void btntambahActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 + input2;
this.lbhasil.setText(""+hasil);
}
private void btnkurangActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 - input2;
this.lbhasil.setText(""+hasil);
}
private void btnkaliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 * input2;
this.lbhasil.setText(""+hasil);
}
private void btnbagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
double input1, input2, hasil;
input1 = Double.parseDouble(this.txtinp1.getText());
input2 = Double.parseDouble(this.txtinp2.getText());
hasil = input1 / input2;
this.lbhasil.setText(""+hasil);
}
public static void main(String args[]) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new KalkulatorSederhana().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnbagi;
private javax.swing.JButton btnkali;
private javax.swing.JButton btnkurang;
private javax.swing.JButton btntambah;
private javax.swing.JLabel lbhasil;
private javax.swing.JTextField txtinp1;
private javax.swing.JTextField txtinp2;
// End of variables declaration
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new KalkulatorSederhana().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnbagi;
private javax.swing.JButton btnkali;
private javax.swing.JButton btnkurang;
private javax.swing.JButton btntambah;
private javax.swing.JLabel lbhasil;
private javax.swing.JTextField txtinp1;
private javax.swing.JTextField txtinp2;
// End of variables declaration
}
PENJELASAN PROGRAM :
Koding di atas merupakan statment pembuatan kalkulator sederhana terdiri dari tambah, kurang, kali, dan bagi. koding di atas juga akan menyertakan output yang sudah tertera dalam hasil perhitungan yang telah di lakukan sebelumnya.
Gambar 1.1 |
Gambar 1.2 |
Gambar 1.3 |
Gambar 1.4 |
keterangan gambar :
Gambar 1.1 merupakan gambar output dari hasil penjumlahan.
Gambar 1.2 merupakan gambar output dari hasil pengurangan.
Gambar 1.3 merupakan gambar output dari hasil pembagian.
Gambar 1.4 merupakan gambar output dari hasil perkalian.
HASIL ANALISA LEKSIKAL :
Gambar 1.5 |
Tidak ada komentar:
Posting Komentar