PROGRAM TO SEARCH A BOOK IN DATABASE AND TELL PRICE IF IT IS AVAILABLE:
#include<iostream>
#include<string.h>
using namespace std;
class bj
{ public:
char name[20];
char title[50];
int stock;
float price;
bj()
{
cout<<"ENTER STOCK";
cin>>stock;
cout<<"ENTER THE TITLE OF BOOK";
fflush(stdin);
cin.getline(title,50);
cout<<"ENTER AUTHOR";
cin.getline(name,20);
cout<<"ENTER PRICE";
cin>>price;
}
};
main()
{ int i,n,g,x,p;
char title[20],author[20];
cout<<"ENTER TYPES OF BOOKS YOU WANT TO ENTER IN DATABASE ";
cin>>g;
bj *b=new bj[g];
cout<<"ENTER THE TITLE AND AUTHOR NAME";
cin>>title>>author;
for(i=0;i<g;i++)
{
if(strcmp(title,b[i].title)&&strcmp(author,b[i].name))
{ p=1;
cout<<"ENTER NO OF BOOKS REQUIRED";
cin>>x;
if(x<b[i].stock)
{x=x*b[i].price;
cout<<x;
}
else
{
cout<<"NOT ENOUGH IN STOCK";
}
break; }
if(p!=1)
{
cout<<"BOOK NOT FOUND";
}
}
}
#include<iostream>
#include<string.h>
using namespace std;
class bj
{ public:
char name[20];
char title[50];
int stock;
float price;
bj()
{
cout<<"ENTER STOCK";
cin>>stock;
cout<<"ENTER THE TITLE OF BOOK";
fflush(stdin);
cin.getline(title,50);
cout<<"ENTER AUTHOR";
cin.getline(name,20);
cout<<"ENTER PRICE";
cin>>price;
}
};
main()
{ int i,n,g,x,p;
char title[20],author[20];
cout<<"ENTER TYPES OF BOOKS YOU WANT TO ENTER IN DATABASE ";
cin>>g;
bj *b=new bj[g];
cout<<"ENTER THE TITLE AND AUTHOR NAME";
cin>>title>>author;
for(i=0;i<g;i++)
{
if(strcmp(title,b[i].title)&&strcmp(author,b[i].name))
{ p=1;
cout<<"ENTER NO OF BOOKS REQUIRED";
cin>>x;
if(x<b[i].stock)
{x=x*b[i].price;
cout<<x;
}
else
{
cout<<"NOT ENOUGH IN STOCK";
}
break; }
if(p!=1)
{
cout<<"BOOK NOT FOUND";
}
}
}