LISTING (PENGGUNAAN KOMPONEN DASAR)
PEMROGRAMAN DEKSTOP
PRAKTEK
PERTAMA
public class FHitung extends javax.swing.JFrame {
/**
Creates new form FHitung */
public
FHitung() {
initComponents();
}
private void
btnHitungActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
float jumlah= Float.parseFloat(txtHarga.getText()) *
Float.parseFloat(txtQty.getText());
TOTAL.setText(Float.toString(jumlah));
DecimalFormat angka= new DecimalFormat("###,###");
TOTAL.setText("TOTAL: Rp."+angka.format(jumlah));
}
private
void btnKeluarActionPerformed(java.awt.event.ActionEvent evt) {
//
TODO add your handling code here:
JOptionPane.showMessageDialog(this,
"Terima Kasih Sudah Membeli "+ txtBarang.getText());
System.exit(0);
}
HASIL OUPUT
:
Ø PRAKTEK KEDUA
package Tugas1;
/**
*
* @author Student
*/
public class FromTugas extends javax.swing.JFrame {
/** Creates new form FromTugas */
public FromTugas() {
initComponents();
}
private void btnHitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
try
{
float hasil =Float.parseFloat
(txtB.getText())*Float.parseFloat (txtB.getText())-
Float.parseFloat
(txtA.getText())*Float.parseFloat (txtC.getText());
lblA.setText(""+
hasil);
if (hasil== 0)
{
lblB.setText("Akar
Kembar");
}
if (hasil > 0)
{
lblB.setText("Akar
X1, X2");
}
if (hasil < 0)
{
lblB.setText("Akar
Imajiner");
}
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(this," Salah Masukan Input");
}
}
private void
btnTutupActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
System.exit(0);
}
HASIL OUPUT
:
*) Jika Input Benar
*) Jiuka Salah
0 komentar:
Posting Komentar