Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project #1 Name: Book Inventory The program will have the following private attr

ID: 3902521 • Letter: P

Question

Project #1 Name: Book Inventory The program will have the following private attributes 1. 2. 3. 4 5. book title cover page (picture name saved in directory) author page count ISBN The program will have the following menu and menu items 1. File Add Book Modify Book ° Display Book Display Inventory o Exit 2. Help o Help Contents About Items menu description: Add Book - will add a new book (must verified unique ISBN) Modify Book - search should be made by ISBN then modify record Display Book - search should be made by ISBN then display all information of the book and display cover page . .

Explanation / Answer

/* Bookshop.cppp*/

#include<iostream>

#include<string.h>

#include<stdlib.h>

using namespace std;

class book

{

char author[20];

char title[20];

char publisher[20];

double price;

int stock;

public:

book();   

void insertdata();

void display();

int search(char[],char[]);

void nocopies(int);

};

book::book()

{

char *author=new char[50];

char * title=new char[50];

char *publisher=new char[50];

price=0;

stock=0;

}

void book::insertdata()

{

cout<<" Enter the name of Book:";

cin>>title;

cout<<" Enter The Name Of Author:";

cin>>author;

cout<<" Enter The name of Publisher:";

cin>>publisher;

cout<<" Enter the Price of book:";

cin>>price;

cout<<" Enter Stock of book:";

cin>>stock;

}

void book::display()

{

cout<<" "<<title<<" "<<author<<" "<<publisher<<" "<<price<<" "<<stock;

}

int book::search(char t[],char a[])

{

if(strcmp(title,t)&&(strcmp(author,a)))

{

return 0;

}

else

{

return 1;

}

}

void book::nocopies(int num)

{

if(stock>=num)

{

cout<<" Title is avilable";

cout<<" Cost of"<<num<<"Books is Rs."<<(price*num);

}

else

{

cout<<" Required copies not in stock";

}

}

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<<" ************Book Store*******************";

cout<<" 1.Insert Details of book 2.Display 3.search 4.exit";

cout<<" Enter Your Choice:";

cin>>ch;

switch(ch)

{

case 1:

cout<<" How many books data u want to enter";

cin>>n;

for(i=0;i<n;i++)

{

b[i].insertdata();

}

break;

case 2:

cout<<" "<<"TITLE"<<" "<<"AUTHOR"<<" "<<"PUBLISHER"<<" "<<"PRICE"<<" "<<"STOCK";

for(i=0;i<n;i++)

{

cout<<" ";

b[i].display();

}

break;

  

case 3:

cout<<" Enter title of required book";

cin>>key_title;

cout<<" 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<<" "<<"TITLE"<<" "<<"AUTHOR"<<" "<<"PUBLISHER"<<" "<<"PRICE"<<" "<<"STOCK";

b[i].display();   

//break;

key=i;

}

}

if(flag==1)   

cout<<" Book is available";

else

{

cout<<" book is Not available";

break;

}   

if(flag==1)

{

cout<<" 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<<" Wrong Choice";

break;

}

}while(ch!=5);

return 0;

}