Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » BeginnersRSS Feeds

Library System

Posted By: Easy Tutor     Category: C++ Programming     Views: 5810

Write a program for Library System.

Code for Library System in C++ Programming

/*www.DailyFreeCode.comDownload Projects, Sourcecodes, Tips and Tricks, Interview FAQs, Hotlinks and more....Logon to www.DailyFreeCode.com*///Library Database
#include <iostream.h>
#include <string.h>
#include <iomanip.h>
#include <conio.h>

class books
{
char **author,**title,**publisher;
int *price;
staticint count;
public:

 books(void);   //constructorvoid getdata(void);
 void display_stock(void);
 void search(void);
};

int books :: count=0;

books :: books(void)
{
  author=newchar*[15];
  title=newchar*[15];
  publisher=newchar*[15];
  price=newint[15];
     for(int i=0;i<15;i++)
       {
         author[i]=newchar;
         title[i]=newchar;
         publisher[i]=newchar;
       }
 }

void books :: getdata(void)
{
  cout<<"\n\n\nEnter Book name:-";
  cin>>title[count];
  cout<<"Enter Author name:-";
  cin>>author[count];
  cout<<"Enter Publisher of book:-";
  cin>>publisher[count];
  cout<<"Enter Price of book:-";
  cin>>price[count];
  count++;
}

void books :: display_stock(void)
{
clrscr();
cout<<"\n\n\n";
cout<<setw(15)<<"Book Name"<<setw(20)<<"Author Name"<<setw(20)<<"Publisher"<<setw(10)<<"Price"<<endl<<endl;
for(int i=0;i<count;i++)
{
cout<<setw(15)<<title[i]<<setw(20)<<author[i]<<setw(20)<<publisher[i]<<setw(10)<<price[i]<<endl;
}
cout<<"\n\nTotal Number of Books are "<<count;
}

void books :: search(void)
{
clrscr();
 char  name[20],writer[20];
 cout<<"\n\n\nEnter Book name:-";
 cin>>name;
 cout<<"Enter Author of Book:-";
 cin>>writer;
 for(int i=0;i<count;i++)
 {
   if((strcmp(title[i],name)==0) && (strcmp(author[i],writer)==0))
     {
     cout<<"\n\nEntered Information Book Available\n";
     cout<<"Price of that book is "<<price[i];
     goto skip;
     }
 }
 cout<<"\n\nBook is not Available in stock\n";
skip:
}

void main()
{
clrscr();
books o1;
int choice;
while(1)
{
cout<<"\n\nChoose your choice\n";
cout<<"1) Entering Information for book\n";
cout<<"2) To See Actual stock\n";
cout<<"3) To Search for a Particular book\n";
cout<<"4) Exit\n";
cout<<"Enter your choice:-";
cin>>choice;
 switch(choice)
 {
   case 1 : o1.getdata();
             break;
   case 2 : o1.display_stock();
             break;
   case 3 : o1.search();
             break;
   case 4 : gotoout;
   default: cout<<"\n\nEnter choice is invalid\nTry again\n";
 }
}
out:
}
  
Share: 


Didn't find what you were looking for? Find more on Library System Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Library System is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!