OOP Practical 4
OOP Practical 4
#include<string.h>
#include<stdlib.h>
}
int main()
{
int ch,n,i,flag=0,copies,key=0;
book b[100];
char bname[50];
char key_title[50],key_author[50];
do
{
cout<<"\n************Book Store*******************";
cout<<"\n 1.Insert Details of book \n 2.Display \n 3.search \n 4.exit";
cout<<"\n Enter Your Choice:";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\n How many books data u want to enter";
cin>>n;
for(i=0;i<n;i++)
{
b[i].insertdata();
}
break;
case 2:
cout<<"\n"<<"TITLE"<<"\t \t "<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t
"<<"STOCK";
for(i=0;i<n;i++)
{
cout<<"\n";
b[i].display();
}
break;
case 3:
cout<<"\n Enter title of required book";
cin>>key_title;
cout<<"\n Enter author of required book";
cin>>key_author;
for(i=0;i<n;i++)
{
if(b[i].search(key_title,key_author))
{
flag=1;
cout<<"\n"<<"TITLE"<<"\t \t "<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t
"<<"STOCK";
b[i].display();
//break;
key=i;
}
}
if(flag==1)
cout<<"\n Book is available";
else
{
cout<<"\n book is Not available";
break;
}
if(flag==1)
{
cout<<"\n Please enter the required number of copies of the book";
cin>>copies;
b[key].nocopies(copies);
}
break;
case 4: exit(EXIT_SUCCESS);
break;
default :
cout<<"\n Wrong Choice";
break;
}
}
while(ch!=5);
return 0;
}
Output:
************Book Store*******************
1.Insert Details of book
2.Display
3.search
4.exit
Enter Your Choice:1
************Book Store*******************
1.Insert Details of book
2.Display
3.search
4.exit
Enter Your Choice:2
B R.K.Roy Navakari 45 23
C T.A.Raja Golden 60 41
************Book Store*******************
1.Insert Details of book
2.Display
3.search
4.exit
Enter Your Choice:3
Title is avilable
Cost of2Books is Rs.90
************Book Store*******************
1.Insert Details of book
2.Display
3.search
4.exit
Enter Your Choice:4