Components :

  • Label
  • TextField
  • Button
  • Panel
First, you Should create project like the example image on top,
and then give any components a variable name if you haven’t trouble soon in the code.
code :
*place the code into button action or right-click on button “Hitung”  events>action
 

 

private void btnhitungActionPerformed(java.awt.event.ActionEvent evt) {
       String namamahasiswa=nmmahasiswa.getText();
       double nilaiabsen = Double.valueOf(absensi.getText());
       double nilaiuts = Double.valueOf(uts.getText());
       double nilaiuas = Double.valueOf(UAS.getText());
       double nilaiakhir = (0.1 * nilaiabsen) + (0.4 * nilaiuts) + (0.5 * nilaiuas);
       char index =0;
       String statusa =” “;
       if(nilaiakhir >= 0 && nilaiakhir <= 49){
           index = ‘E’;
           statusa = “Tidak Lulus”;
       }else if(nilaiakhir >= 50 && nilaiakhir <= 59){
           index = ‘D’;
           statusa = “Kurang”;
       }else if(nilaiakhir >= 60 && nilaiakhir <= 69){
           index = ‘C’;
           statusa = “Cukup”;
       }else if(nilaiakhir >= 70 && nilaiakhir <= 79){
           index =’B’;
           statusa =”Bagus”;
       }else if(nilaiakhir >= 80 && nilaiakhir <= 100){
           index =’A’;
           statusa =”Sangat Bagus”;
       }else{
           index=0;
       }
           nama.setText(“Nama Mahasiswa : “+namamahasiswa);
           nilai.setText(“Nilai Rata-rata : “+nilaiakhir);
           grade.setText(“Grade : “+index);
           status.setText(“Status : “+statusa);
    }
the output project you can add the label on the panel “hasil” like this.
                                  
*Place the code into Button “Bersih”
 
 private void btnbersihActionPerformed(java.awt.event.ActionEvent evt) {
        nmmahasiswa.setText(“”);
        absensi.setText(“”);
        uts.setText(“”);
        UAS.setText(“”);
        nama.setText(“”);
        nilai.setText(“”);
        grade.setText(“”);
        status.setText(“”);
        nmmahasiswa.requestFocus();
    }
*/Button “bersih” for clean all textfield on project
 
*Place the code into Button”Keluar”
private void btnkeluarActionPerformed(java.awt.event.ActionEvent evt) {
        int result = JOptionPane.showConfirmDialog(rootPane, “Apakah Anda Yakin Ingin Keluar dari Aplikasi ini ?”);
        if (result == JOptionPane.YES_OPTION){
            System.exit(0);
        }
    }
*/show the message box if you want to exit on project
Thanks..
hope can need to help..