Tugas Kuliah
Kampus : STIMIK & PKN LPKIA
Program Studi : Manajemen Informatika ( MI )
Konsentrasi : Teknik Informatika ( TI )
Kelas : 1.TI.10
Nama Mahasiswa : Fiqri Ahmad Fadhilah
NRP : 6309030
Matakuliah : P. Struktur Data
Dosen : Dadan Bagenda
Membuat Program Perpustakaan
Coding :
#include <constream.h>
#include <stdio.h>
#include <string.h>
#include <fstream.h>
#include <stdlib.h>
#include <ctype.h>
class perpus
{
private:
char judul[10][30];
char peng[10][30];
int hal[10];
int tahun[10];
public:
int no;
char bjudul[10][30];
char bpeng[10][30];
int bhal[10];
int btahun[10];
int index[10];
void input();
void sojud();
void sopeng();
void sotah();
void sejud();
};
class perpus data;
void main()
{
b:
clrscr();
int i;
cout<<"PROGRAM PERPUSTAKAAN\n"<<endl;
cout<<"1. Input Data Buku"<<endl;
cout<<"2. Sorting by Judul ( Ascending )"<<endl;
cout<<"3. Sorting by Pengarang"<<endl;
cout<<"4. Sorting by Tahun ( output berupa file )"<<endl;
cout<<"5. Searching by Judul Buku"<<endl;
cout<<"6. Exit\n"<<endl;
cout<<"Masukan Pilihan Anda [1-6] : ";
cin>>i;
switch(i)
{
case 1: {
data.input();
goto b;
}
case 2: {
data.sojud();
goto b;
}
case 3: {
data.sopeng();
goto b;
}
case 4: {
data.sotah();
goto b;
}
case 5: {
data.sejud();
goto b;
}
case 6: {
break;
}
default: {
cout<<"Anda Salah Memasukan Kode Pilihan !";
getch();
goto b;
}
}
getch();
}
void perpus::input()
{
b:
clrscr();
int x;
cout<<"Berapa Buku Yang Akan Di Inputkan : ";
cin>>no;
clrscr();
cout<<"INPUT BUKU\n"<<endl;
cout<<"ÉÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍ»"<<endl;
cout<<"º NO º Judul º Pengarang º Jumlah Halaman º Tahun º"<<endl;
cout<<"ÌÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍ͹"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"ÈÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍͼ"<<endl;
for (x=0;x<no;x++)
{
gotoxy(3,6+x);
cout<<x+1;
gotoxy(8,6+x);
gets(judul[x]);
strcpy(bjudul[x],judul[x]);
gotoxy(23,6+x);
gets(peng[x]);
strcpy(bpeng[x],peng[x]);
gotoxy(46,6+x);
cin>>hal[x];
bhal[x]=hal[x];
gotoxy(58,6+x);
cin>>tahun[x];
btahun[x]=tahun[x];
}
getch();
}
void perpus::sojud()
{
clrscr();
char tmp[30];
int it,x,y;
for (x=0;x<no;x++)
{
index[x]=x;
}
for(y=0;y<no;y++)
{
for(x=0;x<no-1;x++)
{
if(strcmp(bjudul[x],bjudul[x+1])>0)
{
strcpy(tmp,bjudul[x]);
strcpy(bjudul[x],bjudul[x+1]);
strcpy(bjudul[x+1],tmp);
it=index[x];
index[x]=index[x+1];
index[x+1]=it;
}
}
}
cout<<"SORTING BY JUDUL\n"<<endl;
cout<<"ÉÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍ»"<<endl;
cout<<"º NO º Judul º Pengarang º Jumlah Halaman º Tahun º"<<endl;
cout<<"ÌÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍ͹"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"ÈÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍͼ"<<endl;
for (x=0;x<no;x++)
{
gotoxy(3,6+x);cout<<x+1;
gotoxy(8,6+x);cout<<judul[index[x]];
gotoxy(23,6+x);cout<<peng[index[x]];
gotoxy(46,6+x);cout<<hal[index[x]];
gotoxy(58,6+x);cout<<tahun[index[x]];
}
getch();
}
void perpus::sopeng()
{
clrscr();
char tmp[30];
int it,x,y;
for (x=0;x<no;x++)
{
index[x]=x;
}
for(y=0;y<no;y++)
{
for(x=0;x<no-1;x++)
{
if(strcmp(bpeng[x],bpeng[x+1])>0)
{
strcpy(tmp,bpeng[x]);
strcpy(bpeng[x],bpeng[x+1]);
strcpy(bpeng[x+1],tmp);
it=index[x];
index[x]=index[x+1];
index[x+1]=it;
}
}
}
cout<<"SORTING BY PENGARANG\n"<<endl;
cout<<"ÉÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍ»"<<endl;
cout<<"º NO º Pengarang º Judul º Jumlah Halaman º Tahun º"<<endl;
cout<<"ÌÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍ͹"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"ÈÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍͼ"<<endl;
for (x=0;x<no;x++)
{
gotoxy(3,6+x);cout<<x+1;
gotoxy(8,6+x);cout<<peng[index[x]];
gotoxy(26,6+x);cout<<judul[index[x]];
gotoxy(49,6+x);cout<<hal[index[x]];
gotoxy(61,6+x);cout<<tahun[index[x]];
}
getch();
}
void perpus::sotah()
{
clrscr();
char tmp[30];
int it,x,y;
for (x=0;x<no;x++)
{
index[x]=x;
}
for(y=0;y<no;y++)
{
for(x=0;x<no-1;x++)
{
if(btahun[x] > btahun[x+1])
{
it=btahun[x];
btahun[x]=btahun[x+1];
btahun[x+1]=it;
it=index[x];
index[x]=index[x+1];
index[x+1]=it;
}
}
}
cout<<"SORTING BY TAHUN\n"<<endl;
cout<<"ÉÍÍÍÍËÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"<<endl;
cout<<"º NO º Tahun º Judul º Pengarang º Jumlah Halaman º"<<endl;
cout<<"ÌÍÍÍÍÎÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"º º º º º º"<<endl;
cout<<"ÈÍÍÍÍÊÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"<<endl;
cout<<"\nInfo : Hasil sorting by tahun ini sudah"<<endl;
cout<<" disimpan berupa file yang bernama"<<endl;
cout<<" sort-tahun.txt ."<<endl;
ofstream ftahun;
ftahun.open("sort-tahun.txt");
ftahun<<"SORTING BY TAHUN"<<endl;
ftahun<<endl;
ftahun<<"-------------------------------------------------------------------"<<endl;
ftahun<<"| NO | Tahun | Judul | Pengarang | Jumlah Halaman |"<<endl;
ftahun<<"-------------------------------------------------------------------"<<endl;
for (x=0;x<no;x++)
{
gotoxy(3,6+x);cout<<x+1;
gotoxy(8,6+x);cout<<tahun[index[x]];
gotoxy(16,6+x);cout<<judul[index[x]];
gotoxy(34,6+x);cout<<peng[index[x]];
gotoxy(57,6+x);cout<<hal[index[x]];
ftahun<<" "<<x+1<<" "<<tahun[index[x]]<<"\t"<<judul[index[x]]<<"\t\t "<<peng[index[x]]<<"\t\t\t"<<hal[index[x]];
ftahun<<endl;
}
ftahun.close();
getch();
}
void perpus::sejud()
{
b:
clrscr();
int x,y,z,t,r;
char cari[30],j;
cout<<"SEARCHING BY JUDUL\n"<<endl;
cout<<"Masukan Judul Buku : ";
cin>>cari;
for(x=0;x<no;x++)
{
t=0;
for (y=0;y<strlen(cari);y++)
{
if (cari[y]==judul[x][y])
{
t=t+1;
if(t==strlen(cari))
{
z=x;
y=strlen(cari);
x=no;
}
}
else y=strlen(cari);
}
}
cout<<"\n";
cout<<"ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"<<endl;
cout<<"º Hasil Pencarian : º"<<endl;
cout<<"ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹"<<endl;
cout<<"º º"<<endl;
cout<<"º º"<<endl;
cout<<"º º"<<endl;
cout<<"º º"<<endl;
cout<<"ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"<<endl;
if (t==strlen(cari))
{
gotoxy(4,8);cout<<"Judul Buku : "<<judul[z]<<endl;
gotoxy(4,9);cout<<"Nama Pengarang : "<<peng[z]<<endl;
gotoxy(4,10);cout<<"Jumlah Halaman : "<<hal[z]<<endl;
gotoxy(4,11);cout<<"Tahun : "<<tahun[z]<<endl;
}
else
{
gotoxy(9,10);
cout<<"Judul Tidak Di Temukan !!";
}
gotoxy(1,14);cout<<"Apakah Anda Mau Mencari Buku Lagi [Y/T] ? ";
do
{
j = toupper(getch());
}
while (!((j=='Y') || (j=='T')));
cout<<j<<endl;
if (j == 'Y')
goto b;
getch();
}
Screen Shoot Program

Screen shoot menu program.

Screen shoot saat menginputkan data buku.

Screen shoot sorting berdasarkan judul buku.

Screen shoot sorting berdasarkan tahun buku.

Screen shoot file keluaran berextensi .txt yang dihasilkan pada saat
sesudah meng-sorting berdasarkan tahun buku.
9 komentar:
bang kirimin master program nyadong penting banget nih salahhudin96@gmail.com
Hallo
terimakasih untuk adminnya:)
sangat membantu programnya
Min saya bisa minta scriptnya kah?klu bisa tolong kirimkan ke email saya msoleh427@gmail.com.dan pake aplikasi apa ya
Pake aplikasi apa ya??
pak admin bu admin , minta script nya boleh . di emailkan di ziuzi44@gmail.com . terimakasih
Tapi kok eror ya mas main cpp nya
Mas scriptnya bisa dikirim lewat email saya ngaa immanuellumbantobing261101@gmail.com
Trimakasih
Boleh minta scriptnya?nanti kirim ke email saya ya doktawandira1@gmail.com
Terima Kasih...
Posting Komentar
Kita disini untuk saling berbagi ilmu maupun informasi .
Terima kasih untuk komentarnya .
Saya sangat menghargai komentar anda walaupun hanya datang dan menyapa "hallo" ..