// This is the last task, but not the last lesson //
//- Memasukkan data buku
//- Menampilkan data buku
//- Transaksi Peminjaman buku
//- Tansaksi Pengembalian buku (jika memungkinkan, ada ketentuan denda apabila terlambat dalam mengembalikan buku)
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <iostream>
using namespace std;
//membuat struct
struct tanggal{
int hari, bln, thn;
};
//pemberian objek pada tiap-tiap struct
struct tanggal pjm, bck, jt;
int charjadiint(char dt[10],int jd){
jd=atoi(dt);
return(jd);
}
char ulang(int *v,char u[10])
{
printf("\n\n\n\tUlangi lagi? [Y/N] ");
gets(u);
*v=strcmp(u,"Y");
return(*v);
}
int main (){
system ("cls");
char nama[20], dt[10], kode[10][10], jb[5][10], u[1], k[4], bayar[100],
daftar[5][100]={"Pemrograman","Sastra Jepang","Teknologi","Matematika","Sains & physics"},
judul[5][100]={"Trick for C++","Katakana & Kanji 2","Cisco Networking","Statistika jilid 2","Anatomi Tubuh Manusia"};
int i, j, jd, a, b, c, d, e, jumlah[10],total[10],v,byr,kmbl;
system("color 4E");
printf("\n\n\n\n\t\t SELAMAT DATANG DI PROGRAM DAFTAR BUKU PERPUSTAKAAN\n");
printf("\n\t\t SMK NEGERI 2 DEPOK SLEMAN YOGYAKARTA\n");
printf("\n\t\t Mrican, Caturtunggal, Depok, Sleman, Yogyakarta 55281\n");
printf("\n\n\n\t Syarat Dan Ketentuan:\n");
printf("\n\t1. Diharap Mengisi Data Peminjaman Buku");
printf("\n\t2. Apabila Terlambat Mengembalikan Buku Akan Dikenakan Denda 1000/hari");
printf("\n\n\n\n\n\t\t\t\tNama Penyewa Buku : ");
gets(nama);
strupr(nama);
system ("cls");
system("color 09");
printf("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
printf(" DAFTAR BUKU PERPUSTAKAAN SMK NEGERI 2 DEPOK SLEMAN YOGYAKARTA \n");
printf(" Mrican, Caturtunggal, Depok, Sleman, Yogyakarta 55281 \n");
printf("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n\n");
printf("-------------------------------------------------------------------------------\n");
printf("| KODE BUKU | JENIS BUKU | NAMA BUKU | TARIF BUKU |\n");
printf("-------------------------------------------------------------------------------\n");
printf("| AA001 | Pemrograman | Trick for C++ | RP. 5.000 |\n");
printf("| AB002 | Sastra Jepang | Katakana & Kanji 2 | RP. 3.000 |\n");
printf("| AC003 | Teknologi | Cisco Networking | RP. 5.000 |\n");
printf("| AD004 | Matematika | Statistika Jilid 2 | RP. 4.000 |\n");
printf("| AE005 | Sains & physics | Anatomi Tubuh Manusia | RP. 2.000 |\n");
printf("-------------------------------------------------------------------------------\n\n");
printf("Nama Penyewa Buku : %s \n", nama);
printf("Masukkan Banyak Data : ");
gets(dt);
jd=charjadiint(dt,jd);
for (i=0;i<jd;i++){
printf("\n\tBuku ke-%d ",i+1);
printf("\n\tKode Buku [AA001, AB002, AC003, AD004, AE005]\t: "); gets(kode[i]);
printf("\n\tJumlah Buku Yang Dipinjam\t : "); gets(jb[i]);
jumlah[i]=atoi(jb[i]);
a=strcmp(kode[i],"AA001");
if(a==0){
total[i]=jumlah[i]*5000;
k[i]=0;
}
b=strcmp(kode[i],"AB002");
if(b==0){
total[i]=jumlah[i]*3000;
k[i]=1;
}
c=strcmp(kode[i],"AC003");
if(c==0){
total[i]=jumlah[i]*5000;
k[i]=2;
}
d=strcmp(kode[i],"AD004");
if(d==0){
total[i]=jumlah[i]*4000;
k[i]=3;
}
e=strcmp(kode[i],"AE005");
if(e==0){
total[i]=jumlah[i]*2000;
k[i]=4;
}
else if(a<0, a>0, b<0,b>0, c<0, c>0, d<0, d>0, e<0, e>0){
system ("cls");
system("color 4E");
printf("\n\n\n\n\n\n\n\n\tMaaf Kode Buku Tidak Tersedia! Harap Masukan Entri Sesuai Kode Buku!\n\n");
system ("pause");
system ("cls");
main();
}
}
//input tanggal peminjaman
cout<<"\nTanggal Pinjam\n";
while(1){
cout<<"Tanggal [DD] : "; cin>>pjm.hari;
if(pjm.hari<=0||pjm.hari>30){
cout<<" Isikan data..\n";
}else{break;}
}
while(1){
cout<<"Bulan [MM] : "; cin>>pjm.bln;
if(pjm.bln<=0||pjm.bln>12){
cout<<" Isikan data..\n";
}else{break;}
}
while(1){
cout<<"Tahun [YYYY] : "; cin>>pjm.thn;
if(pjm.thn<=0){
cout<<" Isikan data..\n";
}else{break;}
}
//input tanggal pengembalian
cout<<"\nTanggal Kembali\n";
while(1){
cout<<"Tanggal [DD] : "; cin>>bck.hari;
if(bck.hari<=0||bck.hari>30){
cout<<" Isikan data..\n";
}else{break;}
}
while(1){
cout<<"Bulan [MM] : "; cin>>bck.bln;
if(bck.bln<=0||bck.bln>12){
cout<<" Isikan data..\n";
}else{break;}
}
while(1){
cout<<"Tahun [YYYY] : "; cin>>bck.thn;
if(bck.thn<=0){
cout<<" Isikan data..\n";
}else{break;}
}
//proses perhitungan denda
int lamaPinjam=(bck.hari-pjm.hari)+((bck.bln-pjm.bln)*30)+((bck.thn-pjm.thn)*360);
int terlambat=lamaPinjam-7;
int denda=0;
if(lamaPinjam>7){
denda =terlambat*1000;
}
//perhitungan jatuh tempo pengembalian
jt.hari = pjm.hari+7;
jt.bln = pjm.bln+(jt.hari/31);
jt.thn = pjm.thn+(jt.bln/13);
if(jt.hari>30){
jt.hari-=30;
}
if(jt.bln>12){
jt.bln-=12;
}
system("cls");
system ("color 0E");
printf("\n\tNama Penyewa Buku : %s", nama);
printf("\n\tJumlah Buku : %s\n\n", dt);
printf("-------------------------------------------------------------------------------\n");
printf("| KODE BUKU | JENIS BUKU | NAMA BUKU | JUMLAH BUKU | SUBTOTAL |\n");
printf("-------------------------------------------------------------------------------\n");
for (i=0;i<jd;i++){
printf(" %5s %11s %13s %7d %10d \n\n",&kode[i],&daftar[k[i]],&judul[k[i]],jumlah[i],total[i]);
}
cout<<"\n Tanggal Pinjam : "<<pjm.hari<<" - "<<pjm.bln<<" - "<<pjm.thn;
cout<<"\n Tanggal Kembali : "<<bck.hari<<" - "<<bck.bln<<" - "<<bck.thn;
cout<<"\n Tanggal Jatuh tempo : "<<jt.hari<<" - "<<jt.bln<<" - "<<jt.thn;
cout<<"\n Lama Peminjaman : "<<lamaPinjam<<" hari";
cout<<"\n Lama Keterlambatan : "<<terlambat<<" hari";
cout<<"\n Denda : Rp."<<denda;
//total[i]=totalmakan+totalminum;
//printf("\nJumlah Total\t\t\t\t\t\t : Rp. %d",total[i]);
//printf("\nMembayar Sejumlah\t\t\t\t\t : Rp. ");
//gets(bayar);
//byr=atoi(bayar);
//kmbl=byr-jumlah;
// printf("\nKembalian\t\t\t\t\t\t : Rp. %d\n",kmbl);
printf("\n\n\n\t\t*****TERIMAKASIH %s ATAS KUNJUNGAN ANDA!***** \n",nama);
v=ulang(&v,u);
if(v==0){
main();
}
getch ();
return 0;
}
DON'T BE SILENT READER GUYS! PLEASE LEAVE A COMMENT, SUBSCRIBE AND FOLLOW MY BLOG :) THANKYOU!
itu codeanya pake c++ apa c aja
BalasHapusSepertinya campuran. Kadang pakai printf kadang pakai cout.
Hapustolong keterangan variabelnya dong, bingung dt, jd
BalasHapus