Java tugas perpustakaan

 import java.util.Scanner;
public class tugas_perpustakaan
{
 public static void main(String[] argumen){
 
 
 System.out.println("=============================================================");
 System.out.println("=============================================================");
 
 System.out.println("");
 System.out.println("Data Peminjam :");
 System.out.println("1. Pelajar");
 System.out.println("2. Mahasiswa");
 System.out.println("3. Umum");
 System.out.println("");
 
 System.out.println("=============================================================");
 System.out.println("=============================================================");
 int status,min_buku=1,min_hari=1,max_buku=15,jml_buku=0,max_hari=7,hari,harga_pelajar=500, 
 harga_mahasiswa=1000,harga_umum=1500 ;
 double diskon_l10=5,diskon_l5=2.5,diskon=0,total_diskon=0, harga_buku=0,
 total_harga_perhari,total_harga_perbuku,total_harga;
 String status_peminjam="";
 
 Scanner s = new Scanner(System.in);
 System.out.print("data peminjam : ");
 status = s.nextInt();
 
 if(status<1 && status>3){
 System.out.println("");
 System.out.println("Maaf, data peminjam tidak ditemukan");
 }
 
 if(status==1){
 harga_buku = harga_pelajar;
 status_peminjam = "Pelajar";
 }else if(status==2){
 harga_buku = harga_mahasiswa;
 status_peminjam = "Mahasiswa";
 }else if(status==3){
 harga_buku = harga_umum;
 status_peminjam = "Umum";
 }
 
 System.out.print("jumlah buku : ");
 jml_buku = s.nextInt();
 
 if(jml_buku<min_buku || jml_buku>max_buku){
 System.out.println("");
 System.out.println("Maaf, jumlah buku minimal 1 buku dan maksimal 15 buku");
 System.exit(0);
 }
 
 if(jml_buku>10){
 diskon = diskon_l10;
 }else if(jml_buku>5){
 diskon = diskon_l5;
 }
 
 total_harga_perbuku = jml_buku*harga_buku;
 
 System.out.print("jumlah hari : ");
 hari = s.nextInt();
 
 if(hari<min_hari || hari>max_hari){
 System.out.println("");
 System.out.println("Maaf, jumlah hari minimal 1 hari dan maksimal 7 hari");
 System.exit(0);
 }
 
 total_harga_perhari = total_harga_perbuku*hari;
 
 if(diskon>0){
 total_diskon = (diskon*total_harga_perhari)/100;
 }
 
 total_harga = total_harga_perhari-total_diskon;
 
 System.out.println("=============================================================");
 System.out.println("=============================================================");
 System.out.println("");
 System.out.println("Status Peminjam : "+status_peminjam);
 System.out.println("Jumlah Buku : "+jml_buku);
 System.out.println("Jumlah Hari : "+hari);
 System.out.println("Harga/buku/hari : "+harga_buku);
 System.out.println("SubTotal : "+total_harga_perhari);
 System.out.println("Diskon : "+diskon+"%");
 System.out.println("Total Diskon : "+total_diskon);
 System.out.println("Total : "+total_harga);
 System.out.println("");
 System.out.println("=============================================================");
 System.out.println("=============================================================");
 
 
 
 
 
 
 }
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *