Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4.  
  5. struct perpus
  6. {
  7. char judul[15];
  8. char pengarang[15];
  9. int id;
  10. };
  11.  
  12. //deklarasi variabel isian...........................
  13. perpus databuku[10];
  14. int brs = 4;
  15. int klm = 15;
  16. int klmx = klm + 20;
  17. int posisi = 0;
  18.  
  19. //isi nip...............................
  20. void tampilan()
  21. {
  22. clrscr();
  23. gotoxy(klm, brs+1); cout << "Inputkan: " << posisi;
  24. gotoxy(klm, brs+2); cout << "===============================";
  25. gotoxy(klm, brs+3); cout << "1. ID Buku: ";
  26. gotoxy(klm, brs+4); cout << "2. Judul Buku: ";
  27. gotoxy(klm, brs+5); cout << "3. Nama Pengarang: ";
  28. }
  29.  
  30.  
  31. //isi nama...............................
  32. void isiid()
  33. {
  34. gotoxy(klmx, brs+3); cin >> databuku[posisi].id;
  35. }
  36.  
  37. //isi nip...............................
  38. void isijudul()
  39. {
  40. gotoxy(klmx, brs+4); gets(databuku[posisi].judul);
  41. }
  42.  
  43. //isi anak...............................
  44. void isipengarang()
  45. {
  46. gotoxy(klmx, brs+5); gets(databuku[posisi].pengarang);
  47. }
  48.  
  49. //tambahkan koreksi data..............................
  50. void tambahKoreksiData()
  51. {
  52. int kor;
  53. do{
  54. gotoxy(klm,brs+12); cout<<"==EDIT DATA==";
  55. gotoxy(klm,brs+13); cout<<"0 = Next ";
  56. gotoxy(klm,brs+14); cout<<"1 = Id Buku ";
  57. gotoxy(klm,brs+15); cout<<"2 = Judul Buku ";
  58. gotoxy(klm,brs+16); cout<<"3 = Nama Pengarang ";
  59. gotoxy(klm,brs+17); cout<<"Pilih Nomor 1/2/3/0 : ";cin>>kor;
  60. switch(kor)
  61. {
  62. case 1 : isiid();break;
  63. case 2 : isijudul();break;
  64. case 3 : isipengarang();break;
  65. default : break;
  66. }
  67. }while(kor !=0);
  68. }
  69.  
  70.  
  71. //cari data...................................
  72. void caridata()
  73. {
  74. int cari,ketemu=false;
  75. clrscr();
  76. cout<<"Cari Judul Buku: ";
  77. cin>>cari;
  78. for(int j=0; j<posisi; j++)
  79. {
  80. if(cari==databuku[j].id)
  81. {
  82. cout<<"Data Ketemu "<<endl;
  83. cout<<" Judul Buku : "<<databuku[j].judul<<endl;
  84. cout<<" Nama Pengarang : "<<databuku[j].pengarang<<endl;
  85. break;
  86. }
  87. else
  88. {
  89. cout<<"Data Yang Dicari Tidak Ditemukan";
  90. }
  91. }
  92. getch();
  93. }
  94.  
  95.  
  96. void laporan()
  97. {
  98. //cetak data............................................
  99. clrscr();
  100. gotoxy(klm, 1); cout <<"================================================";
  101. gotoxy(klm, 2); cout <<"| Nomor | ID Buku | Judul Buku | Pengarang |";
  102. gotoxy(klm, 3); cout <<"================================================";
  103. brs = 6;
  104. for(int a=0;a<posisi; a++)
  105. {
  106. gotoxy(klm+1, brs); cout << a;
  107. gotoxy(klm+10, brs); cout << databuku[a].id;
  108. gotoxy(klm+23, brs); cout << databuku[a].judul;
  109. gotoxy(klm+38, brs); cout << databuku[a].pengarang;
  110.  
  111. brs++;
  112. }
  113. gotoxy(klm, brs); cout <<"================================================";
  114. }
  115.  
  116.  
  117. //program utama....................................
  118. void input()
  119. {
  120. char lagi;
  121.  
  122. do
  123. {
  124. //tampilkan tampilan isian..................
  125. tampilan();
  126.  
  127. //isi data..................................
  128. isiid();
  129. isijudul();
  130. isipengarang();
  131. tambahKoreksiData();
  132.  
  133.  
  134. if (posisi == 9 ) break;
  135. gotoxy(klm, brs+10); cout << "Isi lagi [y/t] : ";
  136. lagi = getche();
  137. posisi++;
  138. }
  139. while (lagi == 'y');
  140. }
  141.  
  142.  
  143. int main()
  144. {
  145. int pilih;
  146. awal:
  147. clrscr();
  148.  
  149. cout<<"\n =====PILIHAN MENU====="<<endl;
  150. cout<<"\n 1. Input ";
  151. cout<<"\n 2. Cari ";
  152. cout<<"\n 3. Tabel ";
  153. cout<<"\n 4. Edit ";
  154. cout<<"\n 5. Selesai ";
  155. cout<<"\n\n Masukkan Bilangan Yang Ingin Dipilih: ";
  156. cin>>pilih;
  157.  
  158. if(pilih==1)
  159. {clrscr();input();goto awal;}
  160. if(pilih==2)
  161. {clrscr();caridata();goto awal;}
  162. if(pilih==3)
  163. {clrscr();laporan();laporan();}
  164. if(pilih==4)
  165. {tambahKoreksiData();}
  166. if(pilih==5)
  167. {cout<<"Program Selesai...";}
  168.  
  169. getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement