top of page

Bookstore Data Management

//This program duplicates bookstore data management at a small level. To increase //the number of books, we could change the array size in line 23. The program has //been developed using array of classes and default constructors

 

 

 

 

#include<iostream.h>

#include<conio.h>

#include<string.h>

class bookstock

{

public:

   char author[21], title[21];

   float price;

   int pos, noc;

 

  bookstock()

  {

   cout<<"enter author name";

   cin>>author;

   cout<<"enter title";

   cin>>title;

 

   cout<<"enter price and stock position";

   cin>>price>>pos;

   cout<<" enter the no of copies available";

   cin>>noc;

    }

}books[4];

 

void searchbook()

{ char bk[21], writer[21];

            cout<<" Enter the book name";

            cin>>bk;

            cout<<" Enter the author's name";

            cin>>writer;

            cout<<"\n\n\n";

            

    for(int i=0; i<4; i++)

    {

            if(strcmp(books[i].author,writer)==0 && strcmp(books[i].title,bk)==0)

            {

                cout<<" Author: "<<books[i].author<<"\n"<<" Title: "<<books[i].title<<"\n"<<" Price: "<<books[i].price<<"\n";

                cout<<" Stock Position:"<< books[i].pos<<"\n"<<" Number of copies available: "<<books[i].noc<<"\n\n\n";

            }

    }

}

 

void display()

{

     for(int i=0; i<4; i++)

    {           cout<<" Author: "<<books[i].author<<"\n"<<" Title: "<<books[i].title<<"\n"<<" Price: "<<books[i].price<<"\n";

                cout<<" Stock Position:"<< books[i].pos<<"\n"<<" Number of copies available: "<<books[i].noc<<"\n"<<"\n"<<"\n"<<"\n";

            

    }

}

    

int main()

  int choice;

  cout<<"1. Search for a book"<<"\n"<<"2. Display all the books available";

  cin>>choice;

  if(choice==1)

  { searchbook();

   }

  else if(choice==2)

  {display();

  }

getch();

return 0;

}

OUTPUT :

bottom of page