mrgokilz

Perpustakaan kecil-kecilan

Oct 1st, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. using namespace std;
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string.h>
  5. inline void baris();
  6. void tampil();
  7. int tarif (char kobu[], char jebu[], int bapin, int *jumbay, int *tabu);
  8.  
  9. main()
  10. {
  11.     char nama[30], kobu[2], jebu[30];// kobu = kode buku, jebu = jenis buku
  12.     int tabu=0, jumbay=0, bapin=0;// tabu = tarif buku, jumbay = jumlah bayar, bapin = banyak pinjam
  13.     cout<<"by : dedi susanto"<<endl<<endl;
  14.     tampil();
  15.     cout<<endl<<endl<<"\t\t\tPerpusatakaan Kecil-kecilan"<<endl;
  16.     cout<<"---------------------------"<<endl;
  17.     cout<<"Nama Penyewa Buku\t : ";cin.getline(nama,30);
  18.     cout<<"Kode Buku [C/K/N]\t : ";cin>>kobu;
  19.     cout<<"Banyak Pinjam\t\t : ";cin>>bapin;
  20.    
  21.     tarif(kobu, jebu, bapin, &jumbay, &tabu);
  22.     system("cls");
  23.     cout<<"Tarif Sewa\t\t\t : Rp. "<<tabu<<endl;
  24.     cout<<"Jenis Buku\t\t\t : "<<jebu<<endl;
  25.     cout<<"Penyewa dengan Nama\t\t : "<<nama<<endl;
  26.     cout<<"Jumlah Bayar Penyewaan Sebesar\t : Rp. "<<jumbay<<endl;
  27. }
  28.  
  29. void baris()
  30. {
  31.     cout<<setfill('-')<<setw(70)<<"-"<<endl<<setfill(' ');
  32. }
  33.  
  34. void tampil()
  35. {
  36.     baris();
  37.     cout<<setiosflags(ios::left)<<setw(20)<<"| Kode Jenis Buku";
  38.     cout<<setw(35)<<"|            jenis Buku"<<setw(15)<<"| Tarif Buku"<<"|"<<endl;
  39.     baris();
  40.     cout<<setw(20)<<"|        C"<<setw(35)<<"| CerPen (Kumpulan Cerita Pendek)";
  41.     cout<<setw(15)<<"|    500"<<"|"<<endl;
  42.     baris();
  43.     cout<<setw(20)<<"|        K"<<setw(35)<<"| Komik";
  44.     cout<<setw(15)<<"|    700"<<"|"<<endl;
  45.     baris();
  46.     cout<<setw(20)<<"|        N"<<setw(35)<<"| Novel";
  47.     cout<<setw(15)<<"|    1000"<<"|"<<endl;
  48.     baris();
  49. }
  50.  
  51. int tarif (char kobu[], char jebu[], int bapin, int *jumbay, int *tabu)
  52. {
  53.     if(strcmp(strupr(kobu),"C")==0)
  54.     {
  55.         strcpy(jebu,"CerPen (Kumpulan Cerita Pendek)");
  56.         *tabu=500;
  57.     }
  58.    
  59.     else if(strcmp(strupr(kobu),"K")==0)
  60.     {
  61.         strcpy(jebu,"Komik");
  62.         *tabu=700;
  63.     }
  64.    
  65.     else if(strcmp(strupr(kobu),"N")==0)
  66.     {
  67.         strcpy(jebu,"Novel");
  68.         *tabu=1000;
  69.     }
  70.    
  71.     else
  72.     {
  73.         strcpy(jebu,"-");
  74.         *tabu=0;
  75.     }
  76.    
  77.     *jumbay=*tabu * bapin;
  78. }
Add Comment
Please, Sign In to add comment