Algoritma
Algoritma
NIM : 2214321009
Semester : 1
Kelas : D Sore
1. Masukkan nama
2. Masukkan tanggal, bulan, dan tahun lahir dengan format dd-mm-yyyy, ex: 16-07-1981
3. Ambil tahun_lahir kemudian kurangkan dengan tahun 2028
Umur = 2028-(tahun_lahir)
5. Tampilkan nama
6. Tampilkan zodiac
7. Tampilkan umur
Flowchart :
Code Program :
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this
license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package javaapplication22;
/**
*
* @author Yodik Kristanto
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
txtOutNama.setEditable(false);
txtOutUmur.setEditable(false);
txtOutZodiac.setEditable(false);
}
/**
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnProses.setText("Proses");
btnProses.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnProsesActionPerformed(evt);
}
});
jLabel1.setText("Nama :");
jLabel3.setText("Hasil :");
jLabel4.setText("Nama :");
jLabel5.setText("Zodiac :");
pack();
}// </editor-fold>
txtOutNama.setText(nama);
zodiak(tglLahir);
umur(tglLahir);
}
umur=2028-tahun;
txtOutUmur.setText(Integer.toString(umur));
}
/**
* @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(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>