Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <conio.h>
- #include <stdio.h>
- struct afton
- {
- char judul_buku[15];
- char pengarang_buku[15];
- int id_buku;
- };
- afton data_buku[10];
- int brs = 4;
- int klm = 15;
- int klmx = klm + 20;
- int posisi = 0;
- void tampilan()
- {
- clrscr();
- gotoxy(klm, brs+1); cout << "# INPUT DATA : " << posisi;
- gotoxy(klm, brs+2); cout << "--------------------------------------" << endl;
- gotoxy(klm, brs+3); cout << "1. ID BUKU : ";
- gotoxy(klm, brs+4); cout << "2. JUDUL BUKU : ";
- gotoxy(klm, brs+5); cout << "3. NAMA PENULIS : ";
- }
- void isiid()
- {
- gotoxy(klmx, brs+3); cin >> data_buku[posisi].id_buku;
- }
- void isijudul()
- {
- gotoxy(klmx, brs+4); gets(data_buku[posisi].judul_buku);
- }
- void isipengarang()
- {
- gotoxy(klmx, brs+5); gets(data_buku[posisi].pengarang_buku);
- }
- void tambahKoreksiData()
- {
- int kor;
- do{
- gotoxy(klm,brs+12); cout<<"-----------------------------------";
- gotoxy(klm,brs+13); cout<<"0 -> NEXT ";
- gotoxy(klm,brs+14); cout<<"1 -> ID BUKU ";
- gotoxy(klm,brs+15); cout<<"2 -> JUDUL BUKU ";
- gotoxy(klm,brs+16); cout<<"3 -> NAMA PENULIS ";
- gotoxy(klm,brs+17); cout<<"# CHOOSE MENU [ 0 1 2 3 ] : "; cin >> kor;
- switch(kor)
- {
- case 1 : isiid();break;
- case 2 : isijudul();break;
- case 3 : isipengarang();break;
- default : break;
- }
- }while(kor !=0);
- }
- void caridata()
- {
- int cari,ketemu=false;
- clrscr();
- cout<<"# CARI JUDUL BUKU : ";
- cin>>cari;
- for(int j=0; j<posisi; j++)
- {
- if(cari==data_buku[j].id_buku)
- {
- cout<<"# DATA DITEMUKAN "<<endl;
- cout<<"# JUDUL BUKU : "<<data_buku[j].judul_buku<<endl;
- cout<<"# NAMA PENULIS : "<<data_buku[j].pengarang_buku<<endl;
- break;
- }
- else
- {
- cout<<"# DATA YANG DICARI TIDAK DITEMUKAN";
- }
- }
- getch();
- }
- void laporan()
- {
- clrscr();
- gotoxy(klm, 1); cout <<"----------------------------------------------------";
- gotoxy(klm, 2); cout <<"| NOMOR | ID BUKU | JUDUL BUKU | PENULIS |";
- gotoxy(klm, 3); cout <<"----------------------------------------------------";
- brs = 6;
- for(int a=0;a<posisi; a++)
- {
- gotoxy(klm+1, brs); cout << a;
- gotoxy(klm+10, brs); cout << data_buku[a].id_buku;
- gotoxy(klm+23, brs); cout << data_buku[a].judul_buku;
- gotoxy(klm+38, brs); cout << data_buku[a].pengarang_buku;
- brs++;
- }
- gotoxy(klm, brs); cout <<"----------------------------------------------------";
- }
- void input()
- {
- char lagi;
- do
- {
- tampilan();
- isiid();
- isijudul();
- isipengarang();
- tambahKoreksiData();
- if (posisi == 9 ) break;
- gotoxy(klm, brs+10); cout << "ISI DATA LAGI ? ( y / t ) : ";
- lagi = getche();
- posisi++;
- }
- while (lagi == 'y');
- }
- int main()
- {
- int pilih;
- awal:
- clrscr();
- cout<<"\n -------------------------------------"<<endl;
- cout<<"\n 1. INPUT DATA ";
- cout<<"\n 2. CARI DATA ";
- cout<<"\n 3. TAMPIL DATA ";
- cout<<"\n 4. EDIT DATA ";
- cout<<"\n 5. KELUAR ";
- cout<<"\n\n PILIH MENU : ";
- cin>>pilih;
- if(pilih==1)
- {clrscr();input();goto awal;}
- if(pilih==2)
- {clrscr();caridata();goto awal;}
- if(pilih==3)
- {clrscr();laporan();laporan();}
- if(pilih==4)
- {tambahKoreksiData();}
- if(pilih==5)
- {cout<<"PROGRAM SELESAI...";}
- getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement