Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
43.4k views
in Computer by (69.4k points)

Define a class to represent a book in a library. Include the following members: Data Members

Book Number, Book Name, Author, Publisher, Price, No. of copies issued, No. of copies Member Functions

(i) To assign initial values

(ii) To issue a book after checking for its availability

(iii) To return a book

(iv) To display book information.

1 Answer

–1 vote
by (64.1k points)
selected by
 
Best answer

#include<iostream.h>

#include<conio.h>

#include<stidio.h>

class Library

{

int BookNo;

char BName[25];

char Author[25];

char Publisher[25];

float Price;

int No_of_Copies;

int No_of_Copies_Issued;

public:

void initial()

{

cout<<end1<<"Enter book number : ";

cout <<BookNo;

cout<<end1<<"Enter book name : ";

gets (Bname);

cout<<end1<<"Enter Author name : ";

gets (Author);

cout<<end1<<"Enter publisher name : ";

gets (publisher);

cout<<end1<<"Enter  price : ";

cin>>Price;

cout<<endl<<"Enter Number of copies: ";

cin>>No_of_Copies;

}

void issue_book ()

{

cout<<"Enter book details......."<<end1;

initial();

if(No_of_Copies>0)

{

cout<<"enter How many book you want to issue:"; 

cin>>No_of_Copies_Issued; 

if(No_of_Copies>=No_of_Copies_Issued)

{

No_of_Copies=No_of_Copies-No_of_Copies_Issued;

cout<<endl<<" "<<No_of_Copies_Issued<<" book is issued..";

display();

 }

 else

{

cout<<”Copies_Issued<<" books is not available in stock..";

}

}

else

{

cout<<"Book is not available";

}

}

 void return_book()

 {

cout<<"enter book detail you want to return...";

cout<<endl<<"Enter Book Number: ";

cin>>BookNo;

cout<<endl<<"Enter Book Name: ";

gets(BName);

No_of_Copies=No_of_Copies+No_of_Copies_Issued;

cout<<endl<<BookNo<<":"<<BName<<"Book is returned......";

 }

void display()

 {

cout<<"Book Number: "<<BookNo<<endl;

cout<<"Book Name: "<<BName<<endl;

cout<<"Author Name: "<<Author<<endl;

cout<<"publisher Name: "<<Publisher<<endl;

cout<<"Price: "<<Price<<endl;

}

};

void main ()

{

clrscr();

Library 11;

int ch;

cout<<"1->Issue book...."<<end1;

cout<<"2->Return Book....."<<end1;

cout<<"Enter your choice .. "<<end1;

cin>>ch;

switch(ch)

{

case 1:

 11.issue_book();

break;

case 2:

11.return_book();

break;

}

getch();

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...