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

Could you please solve the question with C++ and <class> ? thank you Write a pro

ID: 3846309 • Letter: C

Question

Could you please solve the question with C++ and <class> ? thank you

Write a program that simulates a Library Circulation System. The system allows: 1. Adding and saving a new book record. 2. Searching for a book by title. 3. Searching for a book by author. 4. Searching for a book by ISBN number 5. Check out a book 6. Check in a book 7. List books by status. 8. Display library collection sorted by title. 9. Display library collection sorted by author. A library book can be defined as a structure struct book { string author; string title; string isbn; int copies; }; Book status can be defined as an enum enum status (CHECKED_OUT, ON_SHELF); submission 1. source code 2.test cases

Explanation / Answer

#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

struct library

{

char author[20],title[20],pub[20];

int price;

library *next;

};

int sum=0;

void main()

{

clrscr();

library *head=NULL;

library *initial(void);

library *purchase(library *);

//library *sale(library *);void display(library *);

void stock(library *);

void search(library *);

int choice;

while(1)

{

cout<<"Choose your Choice ";

cout<<"1) Initial Data Entry ";

cout<<"2) Purchase of Book ";

cout<<"3) Sales of Book ";

cout<<"4) Stock of Book ";

cout<<"5) Search of Book ";

cout<<"6) Display Books ";

cout<<"7) Exit ";

cout<<"Enter Your Choice:-";

cin>>choice;

switch(choice)

{

case 1 : head=initial();

getch();

break;

case 2 : head=purchase(head);

getch();

break;

// case 3 : head=sale(head);// break;case 4 : stock(head);

getch();

break;

case 5 : search(head);

getch();

break;

case 6 : display(head);

getch();

break;

case 7 : gotoout;

default: cout<<" Invalid Choice TRY AGAIN ";

}

clrscr();

}

out:

}

library *initial(void)

{

clrscr();

library *newl=NULL,*start=NULL,*end=newl;

char ch;

while(1)

{

cout<<" Type y or Y for yes ";

cout<<"Are you Interested in Entering Entry:-";

cin>>ch;

if(ch=='y' || ch=='Y')

{

newl=new library;

cout<<" Enter Author of Book:-";

cin>>newl- >author;

cout<<"Enter Title of Book:-";

cin>>newl->title;

cout<<"Enter Publication of Book:-";

cin>>newl->pub;

cout<<"Enter Price of Book:-";

cin>>newl->price;

sum=sum+newl->price;

if(start==NULL)

start=newl;

else

end->next=newl;

end=newl;

end->next=NULL;

}

elsebreak;

}

return(start);

}

library *purchase(library *start)

{

clrscr();

int pos,count=1,choice;

library *newl,*cnt=start,*head=start;

if(start==NULL)

cout<<" LIST IS EMPTY ";

cout<<" Choose your Choice ";

cout<<"1) Inserting At FIRST POSITION ";

cout<<"2) Inserting In BETWEEN ";

cout<<"3) Inserting At LAST POSITION ";

cout< <"4) Exit ";

cout<< "Enter your choice:-";

cin>>choice;

if(choice >=1 && choice <=3)

{

newl=new library;

cout<<"Enter Author Name :-";

cin>>newl->author;

cout<< "Enter Book Title :-";

cin>>newl->title;

cout<<"Enter Publication :-";

cin>>newl->pub;

cout<<"Enter Price of Book:- ";

cin>>newl->price;

sum=sum+newl->price;

}

switch(choice)

{

case 1 : //for First position

newl->next=head;

head=newl;

break;

case 2 : //for Middle position

read:

cout<<" At which position you want to insert Record:-";

cin>>pos;

while(cnt!=NULL)

{

count++; //cnt for counting variable of type node

cnt=cnt- >next;

}

if(pos<1 || pos>count+1)

{

cout<<" Entered position is Invalid TRY AGAIN ";

goto read;

}

{ //Extra Braces are used as case bypasses intialization of a local variableint c=1;

while(c<pos-1)

{

c++;

start=start->next;

}

}

newl->next=start- >next;

start->next=newl;

break;

case 3 : //for Last positionwhile(start->next!=NULL)

start=start->next;

start->next=newl;

newl->next=NULL;

break;

case 4 : gotoout;

default: cout<<" Entered Choice is Invalid Try again ";

break;

}

out:

return(head);

}

void stock(library *start)

{

clrscr();

int count=0;

while(start!=NULL)

{

count++;

start=start->next;

}

cout<<" Total Number of Books in Stock is "<<count<<endl;

cout<< " Purchase Price of Total Stock is "<<sum;

}

void search(library *start)

{

clrscr();

char author[20],title[20];

cout <<"Enter Book title and its Author name respectively to Search in stock ";

cin>>title>>author;

while(start!=NULL)

{

if(title==start->title)

{

if(author==start->author)

{

cout<<" Book is In Stock ";

cout<<"It Cost Rs"<<start->price;

return;

}

}

}

cout<<" SEARCH IS NOT IN STOCK ";

}

void display(library *start)

{

clrscr();

cout<<setw(10)<<"Book Title"<<setw(25)<<"Author of Book"<<setw(25)<<"Publication"<<setw(20)<<"Price" <<endl<<endl;

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

cout<<"=*";

cout<<endl;

while(start!=NULL)

{

cout<<setw(10)<<start->title<<setw(25)<<start->author< <setw(25)<<start->pub<<setw(20)<<start->price<<endl;

start=start->next;

}

}