Programming / Computing

Library Management System

 This program imitates a small Library management system , it is a fully menu driven programming example and it can take input of a new book and issue or return book and can even can maintain other things........................................................................................................

 

 

 

#include<iostream.h>

#include<conio.h>

 

class lib

{

char name[20];

char publisher[20];

char author[20];

int sno;

int copies;

 

public:

void input();

void display();

void issue();

void ret();

};

 

void lib :: input()

{

cout<<"enter the name of the book  ";

cin>>name;

cout<<"enter the publisher  ";

cin>>publisher;

cout<<"enter the author  ";

cin>>author;

cout<<"enter the serial number  ";

cin>>sno;

cout<<"enter the number of copies  ";

cin>>copies;

}

 

void lib :: display()

{

cout<<"\nenter the name of the book"<<name;

cout<<"\nenter the publisher"<<publisher;

cout<<"\nenter the author"<<author;

cout<<"\nenter the serial number"<<sno;

cout<<"\nenter the number of copies"<<copies;

}

 

void lib :: issue()

{

cout<<"enter the serial number";

int tsno;

cin>>tsno;

 

if(tsno == sno)

{

if(copies >0)

{

copies--;

cout<<"\nsuccessfully issued";

cout<<"\nnumber of books left in library are"<<copies;

}

else

cout<<"\nthe book is not available and already issued";

}

else

cout<<"\nwrong serial number";

}

 

void lib :: ret()

{

cout<<"\nenter the serial number";

int tsno;

cin>>tsno;

if(tsno == sno)

{

copies++;

cout<<"\nsuccessfully returned";

cout<<"\nnumber of books left in library are"<<copies;

}

else

cout<<"\nwrong serial number";

}

 

void main()

{

lib l1;

int mchoice=1,schoice;

 

while(mchoice == 1)

{

cout<<"\nenter your choice \n1 for input \n2 for display \n3 for issue \n4 for return\n";

cout<<"enter ";

cin>>schoice;

 

if(schoice == 1)

l1.input();

else if(schoice == 2)

l1.display();

else if(schoice == 3)

l1.issue();

else if(schoice == 4)

l1.ret();

 

cout<<"\nenter ur choice \n1 for main menu \n2 for exit ";

cin >> mchoice;

}

}

© 2010 All rights reserved.

Make a free websiteWebnode