0
Book management without file handling simple
Create class for Book management system to hold book ISBN,13 digit format,title of the book,author name,price of the book,publishing year.Write a program that performs following operations: 1:Add book information 2:Display Book information 3:Search by Book Id,name,Author name 4:List of books of any author 5:Exit
2 Réponses
0
for(int i=0; i<t; i++)
if(b[i].title==s){
cout<<"Book with title "<<s<<" is found"<<endl;
b[i].displayBook();
flag=false;
break;
}
if(flag)
cout<<"Book is not found"<<endl;
}
if(n==3){
flag=true;
cout<<"Enter book author to search : "<<endl;
cin>>author;
for(int i=0; i<t; i++)
if(b[i].author==author){
cout<<"Book with author "<<author<<" is found"<<endl;
b[i].displayBook();
flag=false;
break;
}
if(flag)
cout<<"Book is not found"<<endl;
}
if(n==4)
break;
}while(true);
case 4:
cout<<"Enter author name : "<<endl;
cin>>author;
for(int i=0; i<t; i++)
if(b[i].author==author){
b[i].displayBook();
}
break;
case 5:
return 0;
break;
}
}while(true);
return 0;
}
0
#include<iostream>
#include <conio.h>
#include <string>
using namespace std;
class Book{
private:
int t;
int yearPublished;
float price;
public:
int id;
string title, author;
void addBook();
void displayBook();
};
void Book::addBook(){
cout<<"please Enter book id : ";
cin>>id;
cout<<"please Enter book title Name : ";
cin>>title;
cout<<"please Enter book author Name : ";
cin>>author;
cout<<"please Enter price of Book : ";
cin>>price;
cout<<"please Enter the publishing year of the Book : ";
cin>>yearPublished;
cout<<"========================================="<<endl;
cout<<endl;
}
void Book::displayBook(){
cout<<"Book ID is= "<<id<<endl;
cout<<"Book Title is = "<<title<<endl;
cout<<"Book Author Name is = "<<author<<endl;
cout<<"Book Price Is = "<<price<<endl;
cout<<"Book Publishing Year is = "<<yearPublished<<endl<<endl;
cout<<"==================================="<<endl;
}
int main(){
int opt;
int t;
string author;
bool flag;
cout<<"=========welcome to Book mangement system=========\n********please Enter no of books you want to add record*******: "<<endl;
cin>>t;
Book b[t];
do{
cout<<"Enter the following : "<<endl;
cout<<"1. Add books information"<<endl;
cout<<"2. Display books information"<<endl;
cout<<"3. Search book"<<endl;
cout<<"4. List all books of any author"<<endl;
cout<<"5. Exit"<<endl;
cout<<"==================================="<<endl;
cin>>opt;
switch(opt){
case 1:
for(int i=0; i<t; i++)
b[i].addBook();
break;
case 2:
for(int i=0; i<t; i++)
b[i].displayBook();
break;
case 3:
int n;
do{
cout<<"1. Search by id "<<endl;
cout<<"2. Search by title "<<endl;
cout<<"3. Search by author "<<endl;
cout<<"4. Exit "<<endl;
cout<<"=========================="<<endl;
cin>>n;
if(n==1){
int x;
flag=true;
cout<<"Enter book id to search: "<<endl;
cin>>x;
for(int i=0; i<t; i++)
if(b[i].id==x){
cout<<"Book with id "<<x<<" is found"<<endl;
b[i].displayBook();
flag=false;
}
if(flag)
cout<<"Book is not found"<<endl;
}
if(n==2){
string s;