Coding aplikasi Java Perpustakaan Soal Semester 1
Soal Semester 1 Teknik Informatika:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class perpustakaan3 extends JFrame {
private JButton tombol, btn2, btn5;
public perpustakaan3()
{
super ("Hardans Perpustakaan");
Container container = getContentPane();
container.setLayout(new FlowLayout());
tombol = new JButton ("Buku kategori Langkah");
tombol.addActionListener
(
new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
String HARI = "" ;
HARI = JOptionPane.showInputDialog(null,"Masukan Jumlah hari \t\t: ", "Maksimal Peminjaman Buku 3 Hari", JOptionPane.PLAIN_MESSAGE);
int a = Integer.parseInt(HARI);
int denda= (a-3)*1000;
int denda2=((a-3)*1000)+(a-7)*1500;
int denda3=((a-3)*1000)+(a-7)*1500+(a-10)*2500;
if(a<=3)
{
JOptionPane.showMessageDialog(null," Anda Tidak Terkena denda "+" "+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
else if((a>3)&&(a<=7))
{
JOptionPane.showMessageDialog(null,"Anda dikenakan Denda Sebesar "+"Rp "+ (denda)+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
else if((a>7)&&(a<=10))
{
JOptionPane.showMessageDialog(null,"Anda dikenakan Denda Sebesar "+"Rp "+ (denda2)+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
else if(a>10)
{
JOptionPane.showMessageDialog(null,"Anda dikenakan Denda Sebesar "+"Rp "+ (denda3)+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
}
}
);
container.add(tombol);
btn2 = new JButton ("Buku Kategori Biasa");
btn2.addActionListener
(
new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
String HARI = "" ;
HARI = JOptionPane.showInputDialog(null,"Masukan Jumlah Hari \t\t: ", "Maksimal Peminjaman Buku 7 Hari", JOptionPane.PLAIN_MESSAGE);
int b = Integer.parseInt(HARI);
int den=(b-7)*5000;
if(b<=7)
{
JOptionPane.showMessageDialog(null,"Anda Tidak Terkena Denda"+""+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
else if(b>7)
{
JOptionPane.showMessageDialog(null,"Anda dikenakan Denda Sebesar"+"Rp "+ (den)+"","Pemberitahuan", JOptionPane.PLAIN_MESSAGE);
}
}
}
);
container.add(btn2);
btn5 = new JButton ("Masukan Komentar anda");
btn5.addActionListener
(
new ActionListener() {
public void actionPerformed (ActionEvent e)
{
String a = JOptionPane.showInputDialog(null,"Masukan Komentar Anda : ","Harap Sopan dan Berakhlak", JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, a);
}
}
);
container.add(btn5);
setSize (500,120);
setLocationRelativeTo(null);
setVisible (true);
}
public static void main (String arg[]) {
perpustakaan3 test = new perpustakaan3();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Save sebagai perpustakaan3.java
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar