rendered paste body#include<iostream.h>#include<fstream.h>#include<graphics.h>#include<conio.h>#include<stdio.h>#include<process.h>#include<dos.h>#include<string.h>int button,x,y,maxx,maxy,one;union REGS i,o;char dat[10];showmouseptr();hidemouseptr();void getmousepos(int *button,int *x,int *y);void restrictmouseptr(int x1,int y1,int x2,int y2);void mouse();void getkey();void welcome();void date();void menu();void searcmenu();void layout1();void layout2();void layout3();void dataentry();void detail();class book { public: char name[50],auther[50],publisher[20],purchdate[12]; long int book_no,price; public: friend istream &operator>>(istream &in,book &temp); friend ostream &operator<<(ostream &out,book &temp); friend ofstream &operator<<(ofstream &bookout,book &temp); friend ifstream &operator>>(ifstream &bookin,book &temp); void search1(); void search2(); void display1(book temp); void open1(); };class library:public book { char issdat[12],retdat[12],sta[2], stdname[20],clas[10]; long int regno,no; public: friend ostream &operator<<(ostream &out,library & temp); friend ofstream &operator<<(ofstream &libout,library &temp); friend ifstream &operator>>(ifstream &libin,library &temp); void issue(); void returnb(); void display2(book temp); void display3(book temp,int loc); void read(); void open2(); };istream &operator>>(istream &in,book &temp)//reading from keyboard { settextstyle(DEFAULT_FONT,0,1); setcolor(15); line(246,159,256,159); gotoxy(32,10); cin>>temp.book_no; setcolor(0); line(246,159,256,159); setcolor(15); line(246,194,256,194); gotoxy(32,12); cin>>temp.name; setcolor(0); line(246,194,256,194); setcolor(15); line(246,245,255,245); gotoxy(32,15); cin>>temp.auther; setcolor(0); line(246,245,255,245); setcolor(15); line(246,296,254,295); gotoxy(32,19); cin>>temp.publisher; setcolor(0); line(246,296,254,295); setcolor(15); line(261,338,270,338); gotoxy(34,22); cin>>temp.purchdate; setcolor(0); line(261,338,270,338); setcolor(15); line(246,383,254,383); gotoxy(32,24); cin>>temp.price; setcolor(0); line(246,383,254,383); return in; }ostream &operator<<(ostream &out,book &temp) //display to console { cout<<" "<<temp.book_no<<" "<<temp.name<<" \t"<<temp.auther<<" \t"<<temp.publisher<<" "<<temp.price; return out; }ofstream &operator<<(ofstream &bookout,book &temp)//write into file bok { bookout.write((char*)&temp.book_no,sizeof(temp.book_no)); bookout.write(temp.name,sizeof(temp.name)); bookout.write(temp.auther,sizeof(temp.auther)); bookout.write(temp.publisher,sizeof(temp.publisher)); bookout.write(temp.purchdate,sizeof(temp.purchdate)); bookout.write((char*)&temp.price,sizeof(temp.price)); return bookout; }ifstream &operator>>(ifstream &bookin,book &temp)//read from file bok { bookin.read((char*)&temp.book_no,sizeof(temp.book_no)); bookin.read(temp.name,sizeof(temp.name)); bookin.read(temp.auther,sizeof(temp.auther)); bookin.read(temp.publisher,sizeof(temp.publisher)); bookin.read(temp.purchdate,sizeof(temp.purchdate)); bookin.read((char*)&temp.price,sizeof(temp.price)); return bookin; }ofstream &operator<<(ofstream &libout,library &temp)//Write into file library { libout.write((char*)&temp.no,sizeof(temp.no)); libout.write(temp.issdat,sizeof(temp.issdat)); libout.write(temp.retdat,sizeof(temp.retdat)); libout.write(temp.sta,sizeof(temp.sta)); libout.write(temp.stdname,sizeof(temp.stdname)); libout.write((char*)&temp.regno,sizeof(temp.regno)); libout.write(temp.clas,sizeof(temp.clas)); return libout; }ifstream &operator>>(ifstream &libin,library &temp)//reading from file library { libin.read((char*)&temp.no,sizeof(temp.no)); libin.read(temp.issdat,sizeof(temp.issdat)); libin.read(temp.retdat,sizeof(temp.retdat)); libin.read(temp.sta,sizeof(temp.sta)); libin.read(temp.stdname,sizeof(temp.stdname)); libin.read((char*)&temp.regno,sizeof(temp.regno)); libin.read(temp.clas,sizeof(temp.clas)); return libin; }void welcome()// welcome screen { int mx=getmaxx(); int my=getmaxy(); setbkcolor(BROWN); setcolor(WHITE); setlinestyle(2,0,2); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); settextstyle(1,0,4); setcolor(BLUE); outtextxy(50,150,"LIBRARY INFORMATION SYSTEM"); setcolor(GREEN); settextstyle(1,0,2); outtextxy(280,390,"DEVELOPED BY:"); outtextxy(440,390,"DIVYA C S"); delay(4000); }void date() //menu with date entry { int mx=getmaxx(); int my=getmaxy(); cleardevice(); setbkcolor(BLACK); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); setcolor(LIGHTBLUE); settextstyle(1,0,2); outtextxy(100,15,"LIBRARY INFORMATION SYSTEM"); setcolor(5); outtextxy(200,70,"MENU"); outtextxy(200,83,"----"); outtextxy(160,100,"1. BOOK ENTRY"); outtextxy(160,140,"2. BOOK ISSUE"); outtextxy(160,180,"3. RETURN BOOK"); outtextxy(160,220,"4. SEARCH"); outtextxy(160,260,"5. DETAIL"); outtextxy(160,320,"6. EXIT"); rectangle(180,350,460,400); outtextxy(200,360,"CURRENT DATE :"); setlinestyle(0,0,1); setcolor(WHITE); line(367,376,372,376); gotoxy(47,24); cin>>dat; setcolor(BLACK); line(367,376,372,376); }void menu()//menu { setbkcolor(BLACK); int mx=getmaxx(); int my=getmaxy(); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); setcolor(LIGHTBLUE); settextstyle(1,0,2); outtextxy(100,15,"LIBRARY INFORMATION SYSTEM"); setcolor(5); outtextxy(200,70,"MENU"); outtextxy(200,83,"----"); outtextxy(160,100,"1. BOOK ENTRY"); outtextxy(160,140,"2. BOOK ISSUE"); outtextxy(160,180,"3. RETURN BOOK"); outtextxy(160,220,"4. SEARCH"); outtextxy(160,260,"5. DETAIL"); outtextxy(160,320,"6. EXIT"); rectangle(180,350,460,400); outtextxy(200,360,"CURRENT DATE :"); gotoxy(47,24); cout<<dat; }void searcmenu() // menu for searching { setbkcolor(BLACK); int mx=getmaxx(); int my=getmaxy(); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); setcolor(LIGHTBLUE); outtextxy(100,100,"SEARCHING"); outtextxy(100,140,"1.BOOK NO"); outtextxy(100,180,"2.BOOK NAME"); outtextxy(100,220,"3.EXIT"); }void layout1() // book entry layout { setbkcolor(BLACK); int mx=getmaxx(); int my=getmaxy(); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); settextstyle(DEFAULT_FONT,0,1); setcolor(CYAN); setlinestyle(0,0,1); rectangle(120,120,500,450); rectangle(120,90,500,120); outtextxy(200,100,"BOOK ENTRY"); outtextxy(150,145,"BOOK NO :"); outtextxy(150,184,"BOOK NAME :" ); outtextxy(150,235,"AUTHER NAME:" ); outtextxy(150,286,"PUBLISHER :" ); outtextxy(150,335,"PURCHASE DATE:" ); outtextxy(150,370,"PRICE :" ); rectangle(390,400,430,430); outtextxy(395,410,"EXIT"); rectangle(330,400,370,430); outtextxy(335,410,"NEW"); }void layout2() // bookdetails display layout { setbkcolor(BLACK); int mx=getmaxx(); int my=getmaxy(); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); settextstyle(DEFAULT_FONT,0,1); settextstyle(DEFAULT_FONT,0,1); setcolor(CYAN); rectangle(120,120,500,450); rectangle(120,80,500,120); outtextxy(200,100,"BOOK DETAILS"); outtextxy(150,145,"BOOK NO :"); outtextxy(150,184,"BOOK NAME :" ); outtextxy(150,235,"AUTHER NAME:" ); outtextxy(150,286,"PUBLISHER :" ); outtextxy(150,335,"PURCHASE DATE:" ); outtextxy(150,370,"PRICE :" ); rectangle(390,400,430,430); outtextxy(395,410,"EXIT"); }void layout3() // layout for issue & return{ setbkcolor(BLACK); int mx=getmaxx(); int my=getmaxy(); setcolor(WHITE); setlinestyle(1,0,1); rectangle(2,2,mx-2,my-2); setcolor(WHITE); rectangle(8,8,mx-8,my-8); settextstyle(DEFAULT_FONT,0,1); setcolor(CYAN); rectangle(120,120,450,450); rectangle(120,80,450,120); outtextxy(200,100,"ISSUE/RETURN BOOK"); outtextxy(150,145,"BOOK NO :"); outtextxy(150,184,"BOOK NAME :" ); outtextxy(150,235,"AUTHER NAME:" ); outtextxy(150,260,"ISSUE DATE :"); outtextxy(150,295,"RETURN DATE:"); outtextxy(150,325,"STUDENTNAME:"); outtextxy(150,355,"REG NO :"); outtextxy(150,395,"CLASS :"); outtextxy(330,260,"STATOUS(I/R):"); rectangle(390,400,430,430); outtextxy(395,410,"EXIT");}void book::display1(book temp)// details display { settextstyle(DEFAULT_FONT,0,1); gotoxy(32,9); cout<<temp.book_no; gotoxy(32,12); cout<<temp.name; gotoxy(32,15); cout<<temp.auther; gotoxy(32,19); cout<<temp.publisher; gotoxy(32,22); cout<<temp.purchdate; gotoxy(32,24); cout<<temp.price; }void library::display2(book temp) //issue book & display { settextstyle(DEFAULT_FONT,0,1); gotoxy(32,10); cout<<temp.book_no; no=temp.book_no; gotoxy(32,12); cout<<temp.name; gotoxy(32,15); cout<<temp.auther; gotoxy(32,17); cout<<dat; strcpy(issdat,dat); setcolor(15); line(400,260,410,260); //line for cursor gotoxy(54,17); cin>>sta; setcolor(0); line(400,260,410,260); gotoxy(32,19); cout<<"--------"; setcolor(15); line(246,300,256,300); gotoxy(32,21); cin>>stdname; setcolor(0); line(246,300,256,300); setcolor(15); line(246,356,256,356); gotoxy(32,23); cin>>regno; setcolor(0); line(246,396,256,396); gotoxy(33,25); cin>>clas; line(246,396,256,396); read(); }void library::display3(book temp,int loc) // return book & display { settextstyle(DEFAULT_FONT,0,1); gotoxy(32,10); cout<<temp.book_no; no=temp.book_no; gotoxy(32,12); cout<<temp.name; gotoxy(32,15); cout<<temp.auther; gotoxy(32,17); cout<<issdat; gotoxy(54,17); cin>>sta; gotoxy(32,19); cout<<dat; strcpy(retdat,dat); gotoxy(32,21); cout<<stdname; gotoxy(32,23); cout<<regno; gotoxy(33,25); cout<<clas; ofstream libout; library lib; libout.open("library.txt",ios::ate|ios::binary); libout.seekp(loc,ios::beg); libout.write((char*)&no,sizeof(no)); libout.write(issdat,sizeof(issdat)); libout.write(retdat,sizeof(retdat)); libout.write(sta,sizeof(sta)); libout.write(stdname,sizeof(stdname)); libout.write((char*)®no,sizeof(regno)); libout.write(clas,sizeof(clas)); }void library::read() { ofstream libout; library lib; libout.open("library.txt",ios::ate|ios::binary); libout.write((char*)&no,sizeof(no)); libout.write(issdat,sizeof(issdat)); libout.write(retdat,sizeof(retdat)); libout.write(sta,sizeof(sta)); libout.write(stdname,sizeof(stdname)); libout.write((char*)®no,sizeof(regno)); libout.write(clas,sizeof(clas)); }void dataentry() // book entry { hidemouseptr(); ifstream bookin; ofstream bookout; book b1; bookout.open("bok.txt",ios::ate|ios::binary); layout1(); cin>>b1; bookout<<b1; bookout.close(); showmouseptr(); }void library::issue() //book issue { int a; setcolor(CYAN); rectangle(50,30,400,70); outtextxy(50,40,"ENTER THE NO OF BOOK"); gotoxy(40,4); cin>>a; cleardevice(); book temp; library l1; ifstream bookin; bookin.open("bok.txt",ios::in|ios::binary); bookin>>temp; while(!bookin.eof()) { if(a==temp.book_no) { layout3(); l1.display2(temp); } bookin>>temp; } bookin.close(); }void library::returnb() //book return { int a,count; setcolor(CYAN); rectangle(50,30,400,70); outtextxy(50,40,"ENTER THE NO OF BOOK"); gotoxy(40,4); cin>>a; book temp; library lib; ifstream libin; ofstream libout; ifstream bookin; libin.open("library.txt",ios::in|ios::binary); bookin.open("bok.txt",ios::in|ios::binary); libin>>lib; bookin>>temp; while(!libin.eof()) { if(a==lib.no&&a==temp.book_no&&strcmp(lib.sta,"I")==0) { // layout3(); int loc=libin.tellg()-sizeof(lib); // libout.open("library.txt", ios::ate|ios::binary); // libout.seekp(loc,ios::beg); layout3(); lib.display3(temp,loc); //libout<<lib; } libin>>lib; bookin>>temp; } libin.close(); }void book::search1() // search with book number { int a,count=1; setcolor(CYAN); rectangle(50,30,500,70); outtextxy(50,40,"ENTER THE NUNBER OF BOOK"); gotoxy(45,4); cin>>a; cleardevice(); book temp; ifstream bookin; bookin.open("bok.txt",ios::in|ios::binary); bookin>>temp; while(!bookin.eof()) { if(a==temp.book_no) { layout2(); temp.display1(temp); count=0; } bookin>>temp; } if(count!=0) { rectangle(240,260,550,350); rectangle(485,320,547,345); outtextxy(487,322,"EXIT"); outtextxy(260,270,"This book no is not existing:"); } bookin.close(); }void book::search2() //SEARCHING WITH BOOK NAME { char a[40]; int count=1; setcolor(CYAN); rectangle(50,30,500,70); outtextxy(50,40,"ENTER THE NAME OF BOOK"); gotoxy(42,4); cin>>a; cleardevice(); book temp; ifstream bookin; bookin.open("bok.txt",ios::in|ios::binary); bookin>>temp; while(!bookin.eof()) { if(strcmp(a,temp.name)==0) { layout2(); temp.display1(temp); count=0; } bookin>>temp; } if(count!=0) { rectangle(240,260,550,350); rectangle(485,320,547,345); outtextxy(487,322,"EXIT"); outtextxy(260,270,"This book is not existing:"); } bookin.close(); }void book::open1() // DISPLAY DETAILS OF BOOK IN THE LIBRARY { int co=0,j=0; int maxx=getmaxx(); int maxy=getmaxy(); setlinestyle(0,0,2); rectangle(3,3,maxx-3,maxy-3); ifstream bookin; book b1; cout<<" BOOKNO"<<" "<<"BOOK NAME"<<"\t"<<"AUTHOR"<<"\t"<<"PUBLISHER"<<"\t "<<"PRICE"; bookin.open("bok.txt",ios::in|ios::binary); bookin>>b1; while(!bookin.eof()) { cout<<"\n "<<"\n"<<b1; co++; if(co>=j+10) { delay(4000); outtextxy(500,450,"enter a key"); getch(); j=j+10; } bookin>>b1; } bookin.close(); } void library::open2() //DISPLAY FOR ISSUE & RETURN { int co=0,j=0; int maxx=getmaxx(); int maxy=getmaxy(); setlinestyle(0,0,2); rectangle(3,3,maxx-3,maxy-3); ifstream libin; library b1; libin.open("library.txt",ios::in|ios::binary); libin>>b1; while(!libin.eof()) { cout<<"\n "<<"\n"<<b1; co++; if(co>=j+10) { delay(4000); outtextxy(500,450,"enter a key"); getch(); j=j+10; } libin>>b1; } libin.close(); }ostream &operator<<(ostream &out,library &temp) // DISPLAY TO THE CONSOLE { cout<<" "<<temp.no<<"\t"<<temp.issdat<<"\t"<<temp.retdat<<"\t"<<temp.sta<<" "<<temp.stdname<<"\t"<<temp.regno<<" \t"<<temp.clas; return out; }void getkey() //FIND THE POSITION OF MOUSE , CALL THE FUNCTIONS { book b1; library l1; if((x>=160&&x<=312&&y>=107&&y<=118)&&(button &1)==1)// book entry { cleardevice(); setbkcolor(BLACK); dataentry(); } //EXIT TO MENU if((x>=388&&x<=420&&y>=400&&y<=430)&&(button &1)==1) { cleardevice(); setbkcolor(BLACK); menu(); } //CONTINUE THE BOOKENTRY if((x>=331&&x<=369&&y>=400&&y<=430)&&(button &1)==1) { cleardevice(); dataentry(); } //ISSUE BOOK if((x>=160&&x<=300&&y>=147&&y<=158)&&(button &1)==1) { cleardevice(); setbkcolor(BLACK); l1.issue(); } //RETURN BOOK if((x>=160&&x<=326&&y>=185&&y<=199)&&(button &1)==1) { cleardevice(); setbkcolor(BLACK); l1.returnb(); } //search MENU if((x>=160&&x<=268&&y>=225&&y<=243)&&(button &1)==1) { cleardevice(); setcolor(CYAN); searcmenu(); } //SEARCH bookno if((x>=100&&x<=202&&y>=146&&y<=163)&&(button &1)==1) { cleardevice(); setbkcolor(BLACK); setcolor(CYAN); b1.search1(); } //SEARCH book name if((x>=97&&x<=230&&y>=184&&y<=200)&&(button &1)==1) { cleardevice(); setbkcolor(BLACK); b1.search2(); } //exit from search if((x>=485&&x<=546&&y>=321&&y<=345)&&(button &1)==1) { cleardevice(); searcmenu(); } //exit to menu if((x>=100&&x<=160&&y>=227&&y<=239)&&(button &1)==1) { cleardevice(); menu(); } //detail printing if((x>=160&&x<=258&&y>=257&&y<=281)&&(button &1)==1) { cleardevice(); b1.open1(); getch(); cleardevice(); menu(); } //exit from pgm if((x>=160&&x<=229&&y>=326&&y<=341)&&(button &1)==1) { exit(0); } }void mouse() // mouse position { maxx=getmaxx(); maxy=getmaxy(); showmouseptr(); restrictmouseptr(0,0,maxx-1,maxy-1); while(1) { getmousepos( &button, &x, &y); getkey(); showmouseptr(); gotoxy(65,2); printf("x=%3d,y=%3d",x,y); } }showmouseptr() // show the mouse pointer { i.x.ax=1; int86(0X33,&i,&o); return(i.x.ax); }hidemouseptr() //hide the mouse pointer { i.x.ax=2; int86(0X33,&i,&o); return(i.x.ax); }void restrictmouseptr( int x1,int y1,int x2,int y2) { i.x.ax=7; i.x.cx=x1; i.x.dx=x2; int86(0X33,&i,&o); i.x.ax=8; i.x.cx=y1; i.x.dx=y2; int86(0X33,&i,&o); }void getmousepos(int * button,int *x,int *y) //get the position of pointer { i.x.ax=3; int86(0X33,&i,&o); *button=o.x.bx; *x=o.x.cx; *y=o.x.dx; }void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"d:\\tc\\BGI"); setbkcolor(BLACK); welcome(); date(); mouse(); getch(); }