Answer to Question #202076 in C++ for sayyam butt

Question #202076

library managment system in object oriented programming


1
Expert's answer
2021-06-02T07:49:03-0400
using namespace std;


// Create a structure called library to hold accession number, title of the book, author 
// name, price of the book, and flag indicating whether book is issued or not.


#define NO_OF_BOOKS	100
struct Library
{
	int AccessionNo;
	string Title;
	string Author;
	float Price;
	int Flag;
};






main(void)
{
	int n=0,Flag=1,r,k;	
	struct Library B[NO_OF_BOOKS];
	string Auth;
	n=0;
	while(Flag)
	{
		cout<<"\n\nPress-1 to Add book information";
		cout<<"\nPress-2 to display book information";
		cout<<"\nPress-3 to display list of all books of given author";
		cout<<"\nPress-4 to display title of specidfied book";
		cout<<"\nPress-5 to display the count of books in the library";
		cout<<"\nPress-6 to list the books in Accession Number";
		cout<<"\nPress-7 to EXIT";
		Flag=0;
		while(Flag<1 || Flag>7)
		{
			printf("Enter Choice (1 to 7): "); scanf("%d",&Flag);
		}
		if(Flag==1)
		{
			cout<<"\nEnter Accession No.: "; cin>>B[n].AccessionNo;
			cout<<"\nEnter Title        : "; cin>>B[n].Title;
			cout<<"\nEnter Author       : "; cin>>B[n].Author;
			cout<<"\nEnter Price        : "; cin>>B[n].Price;
			cout<<"\nEnter Flag         : "; cin>>B[n].Flag;
			cout<<"\nBook added successfully.";
			n=n+1;
		}
		
		if(Flag==2)
		{
			for(r=0;r<n;r++)
			{
				cout<<"\n\t"<<B[r].AccessionNo<<"\t"<<B[r].Title<<"\t"<<B[r].Author<<"\t"<<B[r].Price;
				if(B[r].Flag) 	cout<<"\tNot Issued";
				else			cout<<"\tIssued";
			}
		}
		
		if(Flag==3)
		{
			cout<<"\nEnter Accession Name: "; cin>>Auth;
			for(r=0;r<n;r++)
			{
				if(Auth == B[r].Author)
				{
					cout<<"\n\t"<<B[r].AccessionNo<<"\t"<<B[r].Title<<"\t"<<B[r].Author<<"\t"<<B[r].Price;
					if(B[r].Flag) 	cout<<"\tNot Issued";
					else			cout<<"\tIssued";
				}
			}
		}
		if(Flag==4)
		{
			printf("\nEnter Accession No.: "); scanf("%d",&k);
			for(r=0;r<n;r++)
			{
				if(k==B[r].AccessionNo)
				{
					cout<<"\n\t"<<B[r].AccessionNo<<"\t"<<B[r].Title<<"\t"<<B[r].Author<<"\t"<<B[r].Price;
					if(B[r].Flag) 	cout<<"\tNot Issued";
					else			cout<<"\tIssued";
				}
			}
		}
		if(Flag==5)
		{
			cout<<"\nTotal No. of books in library = "<<n;
		}
		
		if(Flag==6)
		{
			for(r=0;r<n;r++)
			{
				cout<<"\n\t"<<B[r].AccessionNo<<"\t"<<B[r].Title<<"\t"<<B[r].Author<<"\t"<<B[r].Price;
				if(B[r].Flag) 	cout<<"\tNot Issued";
				else			cout<<"\tIssued";
			}
		}
		if(Flag==7) exit(0);


	}
	


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog