Advertisement
amrulHarahap

Program Penitipan Hewan

Dec 19th, 2019
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.61 KB | None | 0 0
  1. // Program Penitipan Hewan Peliharaan
  2. // Task file 066-P09.pptx
  3. // Amrul Mubarak Harahap
  4. // 19T03 - 1901098
  5.  
  6. #include <string>
  7. #include <iostream>
  8. #include <iomanip>
  9. #include <cstring>
  10. using namespace std;
  11.  
  12. struct {
  13. char jenis,kode,jnsh[10],jp[20];
  14. int jh,bp,st;
  15. } nama[5];
  16.  
  17.  
  18. int jh,tb,ub,uk,a;
  19. string petugas,pemilik;
  20. char ulang;
  21.  
  22. void judul(){
  23.   cout<<"\t\tPENITIPAN HEWAN PELIHARAAN"<<endl;
  24.   cout<<"\t\t     'MEAOW PET CARE'"<<endl;
  25. }
  26.  
  27. void garis(){
  28. int max,i;
  29. string pilih="=";
  30. max=53;
  31.  
  32. for(i = 1; i <= max; i++){cout<<pilih;}
  33. cout<<endl;
  34. }
  35.  
  36. void total_bayar(){
  37.   tb=tb+nama[a].st;
  38. }
  39.  
  40.  
  41. int main(){
  42.   menu:
  43.   system("cls");
  44.   judul();
  45.   garis();
  46.   cout<<"Nama Petugas : ";getline(cin, petugas);
  47.   cout<<"Nama Pemilik : ";getline(cin, pemilik);
  48.   cout<<"Jumlah Hewan : ";cin>>jh;
  49.   cout<<endl;
  50.  
  51.   for(a=1;a<=jh;a++){
  52.     cout<<"Hewan ke-"<<a<<endl;
  53.     cout<<"Kode Jenis Hewan [K/H]: ";cin>>nama[a].jenis;
  54.     cout<<"Kode Perawatan   [1/2]: ";cin>>nama[a].kode;
  55.     cout<<"Jumlah Hewan          : ";cin>>nama[a].jh;
  56.     cout<<endl;
  57.  
  58.     if(nama[a].jenis=='K'||nama[a].jenis=='k')
  59.     {
  60.       strcpy(nama[a].jnsh,"Kucing");
  61.        if(nama[a].kode=='1')
  62.        {
  63.         strcpy(nama[a].jp,"Lux");
  64.         nama[a].bp=250000;
  65.        }
  66.        else
  67.        {
  68.         strcpy(nama[a].jp,"Intensif");
  69.         nama[a].bp=300000;
  70.        }
  71.     }
  72.     else if(nama[a].jenis=='H'||nama[a].jenis=='h'){
  73.       strcpy(nama[a].jnsh,"Hamster");
  74.       if(nama[a].kode=='1'){
  75.         strcpy(nama[a].jp,"Lux");
  76.         nama[a].bp=150000;
  77.       }
  78.       else {
  79.         strcpy(nama[a].jp,"Intensif");
  80.         nama[a].bp=100000;
  81.        }
  82.     }
  83.     else {
  84.     cout<<"Maaf Kode Jenis Hewan Salah";
  85.     }
  86.   }
  87.    
  88.   system("cls");
  89.   cout<<endl;
  90.   judul();
  91.   garis();
  92.   cout<<"Nama Petugas : "<<petugas<<endl;
  93.   cout<<"Nama Pemilik : "<<pemilik<<endl;
  94.   garis();
  95.   cout<<"No. Jenis    Jenis       Biaya      Jumlah  Subtotal"<<endl;
  96.   cout<<"    Hewan    Perawatan   Perawatan  Hewan"<<endl;
  97.   garis();
  98.  
  99.   for(a=1;a<=jh;a++){
  100.   nama[a].st=nama[a].bp*nama[a].jh;
  101.   cout<<" "<<a<<"  "<<nama[a].jnsh<<"   "<<nama[a].jp;
  102.   cout<<"    "<<nama[a].bp<<"     "<<nama[a].jh<<"       "<<nama[a].st<<endl;
  103.  
  104.   total_bayar();
  105.   }
  106.  
  107.   garis();
  108.  
  109.   cout<<"\t\t\tTotal Bayar  :Rp. "<<tb<<endl;
  110.   cout<<"\t\t\tUang Bayar   :Rp. ";cin>>ub;
  111.   uk=ub-tb;
  112.   cout<<"\t\t\tUang Kembali :Rp. "<<uk<<endl;
  113.   garis();
  114.  
  115.   cout << "\n\t\t\t\tINGIN MENGULANG?(Y/T): "; cin >> ulang;
  116.  
  117.     if(ulang == 'Y' || ulang == 'y'){
  118.       goto menu;
  119.     } else {
  120.       goto akhir;
  121.     }
  122.  
  123.   akhir:
  124.   return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement