Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4.  
  5. struct afton
  6. {
  7. char judul_buku[15];
  8. char pengarang_buku[15];
  9. int id_buku;
  10. };
  11.  
  12. afton data_buku[10];
  13. int brs = 4;
  14. int klm = 15;
  15. int klmx = klm + 20;
  16. int posisi = 0;
  17.  
  18. void tampilan()
  19. {
  20. clrscr();
  21. gotoxy(klm, brs+1); cout << "# INPUT DATA : " << posisi;
  22. gotoxy(klm, brs+2); cout << "--------------------------------------" << endl;
  23. gotoxy(klm, brs+3); cout << "1. ID BUKU : ";
  24. gotoxy(klm, brs+4); cout << "2. JUDUL BUKU : ";
  25. gotoxy(klm, brs+5); cout << "3. NAMA PENULIS : ";
  26. }
  27.  
  28.  
  29. void isiid()
  30. {
  31. gotoxy(klmx, brs+3); cin >> data_buku[posisi].id_buku;
  32. }
  33.  
  34. void isijudul()
  35. {
  36. gotoxy(klmx, brs+4); gets(data_buku[posisi].judul_buku);
  37. }
  38.  
  39. void isipengarang()
  40. {
  41. gotoxy(klmx, brs+5); gets(data_buku[posisi].pengarang_buku);
  42. }
  43.  
  44. void tambahKoreksiData()
  45. {
  46. int kor;
  47. do{
  48. gotoxy(klm,brs+12); cout<<"-----------------------------------";
  49. gotoxy(klm,brs+13); cout<<"0 -> NEXT ";
  50. gotoxy(klm,brs+14); cout<<"1 -> ID BUKU ";
  51. gotoxy(klm,brs+15); cout<<"2 -> JUDUL BUKU ";
  52. gotoxy(klm,brs+16); cout<<"3 -> NAMA PENULIS ";
  53. gotoxy(klm,brs+17); cout<<"# CHOOSE MENU [ 0 1 2 3 ] : "; cin >> kor;
  54. switch(kor)
  55. {
  56. case 1 : isiid();break;
  57. case 2 : isijudul();break;
  58. case 3 : isipengarang();break;
  59. default : break;
  60. }
  61. }while(kor !=0);
  62. }
  63.  
  64.  
  65. void caridata()
  66. {
  67. int cari,ketemu=false;
  68. clrscr();
  69. cout<<"# CARI JUDUL BUKU : ";
  70. cin>>cari;
  71. for(int j=0; j<posisi; j++)
  72. {
  73. if(cari==data_buku[j].id_buku)
  74. {
  75. cout<<"# DATA DITEMUKAN "<<endl;
  76. cout<<"# JUDUL BUKU : "<<data_buku[j].judul_buku<<endl;
  77. cout<<"# NAMA PENULIS : "<<data_buku[j].pengarang_buku<<endl;
  78. break;
  79. }
  80. else
  81. {
  82. cout<<"# DATA YANG DICARI TIDAK DITEMUKAN";
  83. }
  84. }
  85. getch();
  86. }
  87.  
  88.  
  89. void laporan()
  90. {
  91. clrscr();
  92. gotoxy(klm, 1); cout <<"----------------------------------------------------";
  93. gotoxy(klm, 2); cout <<"| NOMOR | ID BUKU | JUDUL BUKU | PENULIS |";
  94. gotoxy(klm, 3); cout <<"----------------------------------------------------";
  95. brs = 6;
  96. for(int a=0;a<posisi; a++)
  97. {
  98. gotoxy(klm+1, brs); cout << a;
  99. gotoxy(klm+10, brs); cout << data_buku[a].id_buku;
  100. gotoxy(klm+23, brs); cout << data_buku[a].judul_buku;
  101. gotoxy(klm+38, brs); cout << data_buku[a].pengarang_buku;
  102.  
  103. brs++;
  104. }
  105. gotoxy(klm, brs); cout <<"----------------------------------------------------";
  106. }
  107.  
  108.  
  109. void input()
  110. {
  111. char lagi;
  112.  
  113. do
  114. {
  115. tampilan();
  116.  
  117. isiid();
  118. isijudul();
  119. isipengarang();
  120. tambahKoreksiData();
  121.  
  122.  
  123. if (posisi == 9 ) break;
  124. gotoxy(klm, brs+10); cout << "ISI DATA LAGI ? ( y / t ) : ";
  125. lagi = getche();
  126. posisi++;
  127. }
  128. while (lagi == 'y');
  129. }
  130.  
  131.  
  132. int main()
  133. {
  134. int pilih;
  135. awal:
  136. clrscr();
  137.  
  138. cout<<"\n -------------------------------------"<<endl;
  139. cout<<"\n 1. INPUT DATA ";
  140. cout<<"\n 2. CARI DATA ";
  141. cout<<"\n 3. TAMPIL DATA ";
  142. cout<<"\n 4. EDIT DATA ";
  143. cout<<"\n 5. KELUAR ";
  144. cout<<"\n\n PILIH MENU : ";
  145. cin>>pilih;
  146.  
  147. if(pilih==1)
  148. {clrscr();input();goto awal;}
  149. if(pilih==2)
  150. {clrscr();caridata();goto awal;}
  151. if(pilih==3)
  152. {clrscr();laporan();laporan();}
  153. if(pilih==4)
  154. {tambahKoreksiData();}
  155. if(pilih==5)
  156. {cout<<"PROGRAM SELESAI...";}
  157.  
  158. getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement