Full width home advertisement

Travel the world

Climb the mountains

Post Page Advertisement [Top]

SOURCE CODE
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class penilaian extends JFrame implements ActionListener
{
 
                JLabel lb1 = new JLabel("NIM                     :");
                JLabel lb2 = new JLabel("NAMA                 :");
                JLabel lb3 = new JLabel("Nilai UTS            :");
                JLabel lb4 = new JLabel("Nilai UAS      :");
                JLabel lb5 = new JLabel("Nilai Akhir          :");
                JLabel lb6 = new JLabel("Nilai Huruf          :");
                JLabel lb7 = new JLabel("SISTEM INFORMASI NILAI MAHASISWA");
   
                JTextField tfNIM = new JTextField();
                JTextField tfNama = new JTextField();
                JTextField tfUTS = new JTextField();
                JTextField tfUAS = new JTextField();
                JTextField tfakhir = new JTextField();
                JTextField tfhuruf = new JTextField();
   
                JButton btnHITUNG = new JButton("HITUNG");
                JButton btnINPUTLAGI = new JButton("INPUT LAGI");
                JButton btnSELESAI = new JButton("SELESAI");
                JPanel panel = new JPanel();
 
    penilaian()
    {
                setTitle("15.01.53.0044 / DHIKA BAGAS WHISNU AJI / A2");
                setDefaultCloseOperation(JFrame.EXITONCLOSE);
                setSize(520,490);
                setLocationRelativeTo(null);
                panel.setLayout(null);
       
                lb7.setBounds(30,40,500,30);
                lb7.setFont(new Font("DigifaceWide", Font.PLAIN, 20));
                add(lb7, BorderLayout.CENTER);
     
                lb1.setBounds(10,100,120,30);
                tfNIM.setBounds(120,100,290,30);
                lb2.setBounds(10,140,120,30);
                tfNama.setBounds(120,140,290,30);
                lb3.setBounds(10,180,120,30);
                tfUTS.setBounds(120,180,80,30);
                lb4.setBounds(240,180,120,30);
                tfUAS.setBounds(330,180,80,30);
                lb5.setBounds(10,220,120,30);
                tfakhir.setBounds(120,220,80,30);
                lb6.setBounds(10,260,120,30);
                tfhuruf.setBounds(120,260,80,30);
     
                btnHITUNG.setBounds(90,400,100,30);
                btnINPUTLAGI.setBounds(200,400,100,30);
                btnSELESAI.setBounds(310,400,100,30);
       
                panel.add(lb7);
                panel.add(lb1);
                panel.add(tfNIM);
                panel.add(lb2);
                panel.add(tfNama);
                panel.add(lb3);
                panel.add(tfUTS);
                panel.add(lb4);
                panel.add(tfUAS);
                panel.add(lb5);
                panel.add(tfakhir);
                panel.add(lb6);
                panel.add(tfhuruf);
       
                panel.add(btnHITUNG);
                panel.add(btnINPUTLAGI);
                panel.add(btnSELESAI);
       
                btnHITUNG.addActionListener(this);
                btnINPUTLAGI.addActionListener(this);
                btnSELESAI.addActionListener(this);
       
                add(panel);
    }

public void actionPerformed(ActionEvent e)
{
                Object objek = e.getSource();
               
    if(objek==btnHITUNG)
    {
                String d1 = tfUTS.getText();
                String d2 = tfUAS.getText();
       
                double a = Integer.parseInt(d1);
                double b = Integer.parseInt(d2);
       
                int akhir = (int) ((0.4 * a) + (0.6 * b) );
                char huruf = (char) akhir;
         
                tfakhir.setText(new String().valueOf(akhir));
       
                akhir=Integer.parseInt(tfakhir.getText());
       
            if (akhir>=80) 
            {
                                huruf='A';
            }
            else if(akhir>=65) 
            {
                                huruf='B';
            }
else if(akhir>=50)
{
                                huruf='C';
            }
            else if(akhir>=40)
            {
                                huruf='D';
            }
            else  
            {
                huruf='E';
            }
           
                tfhuruf.setText(new String().valueOf(huruf));

    }
    else if(objek==btnINPUTLAGI)
    {
                tfNIM.setText("");
                tfNama.setText("");
                tfUTS.setText("");
                tfUAS.setText("");
                tfakhir.setText("");
                tfhuruf.setText("");
                tfNIM.requestFocus();
       
                JOptionPane.showMessageDialog(null, "Silahkan Input Lagi ");

    }
    else if (objek==btnSELESAI)
    {
                JOptionPane.showMessageDialog(null,"Terima kasih telah melihat program saya ");
                System.exit(1);
    }
}

public static void main(String[]args)
                {
                penilaian frame=new penilaian();
                frame.setSize(520,490);
                frame.setVisible(true);
                }

}

TAMPILAN OUTPUT PROGRAM

No comments:

Post a Comment

Bottom Ad [Post Page]