Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q.Write the key points of this (Project program) in detail. #include #include #include #include using namespace std; class Library { public: void Menu(); void add_book();

Q.Write the key points of this (Project program) in detail.

#include #include #include #include using namespace std; class Library { public: void Menu(); void add_book(); void show_books(); void update_book(); void del_book(); }; void Library::Menu() { system("cls"); cout<<" \t\t\t\tMenu"; cout<<" 1. Add New Book"; cout<<" 2. Display Books"; cout<<" 3. Update Book"; cout<<" 4. Delete Book"; cout<<" 5. Exit"; } void Library::add_book() { system("cls"); fstream file; int no_copy; string b_name,a_name,b_id; cout<<" \t\t\t\t ADD a Book"; cout<<" Book ID : "; cin>>b_id; cout<<" \t\t\t Book Name : "; cin>>b_name; cout<<" Author Name : "; cin>>a_name; cout<<" \t\t\t No. of Copies : "; cin>>no_copy; file.open("D://book.txt",ios::out|ios::app); file<<" "<>b_id>>b_name>>a_name>>no_copy; while(!file.eof()) { cout<<" "<>b_id>>b_name>>a_name>>no_copy; } file.close(); } } void Library::update_book() { system("cls"); fstream file,file1; int no_copy,no_co,j=0; string b_name,b_na,a_name,a_na,b_idd,b_id; cout<<" \t\t\t\tUpdate Book Record"; file1.open("D://book1.txt",ios::app|ios::out); file.open("D://book.txt",ios::in); if(!file) cout<<" File Openning Error..."; else { cout<<" Book ID : "; cin>>b_id; file>>b_idd>>b_name>>a_name>>no_copy; while(!file.eof()) { if(b_id == b_idd) { system("cls"); cout<<" \t\t\t\tUpdate Book Record"; cout<<" New Book Name : "; cin>>b_na; cout<<" \t\t\tAuthor Name : "; cin>>a_na; cout<<" No. of Copies : "; cin>>no_co; file1<<" "<>b_idd>>b_name>>a_name>>no_copy; } if(j == 0) cout<<" Book ID Not Found..."; } file.close(); file1.close(); remove("D://book.txt"); rename("D://book1.txt","D://book.txt"); } void Library::del_book() { system("cls"); fstream file,file1; int no_copy,j=0; string b_id,b_idd,b_name,a_name; cout<<" \t\t\t\tDelete Book Record"; file1.open("D://book1.txt",ios::app|ios::out); file.open("D://book.txt",ios::in); if(!file) cout<<" File Openning Error..."; else { cout<<" Book ID : "; cin>>b_id; file>>b_idd>>b_name>>a_name>>no_copy; while(!file.eof()) { if(b_id == b_idd) { system("cls"); cout<<" \t\t\t\tDelete Book Record"; cout<<" One Book is Deleted Successfully..."; j++; } else file1<<" "<>b_idd>>b_name>>a_name>>no_copy; } if(j == 0) cout<<" Book ID Not Found..."; } file.close(); file1.close(); remove("D://book.txt"); rename("D://book1.txt","D://book.txt"); } main() { int choice; char z; Library b; p: b.Menu(); cout<<" enter choice between 1-5 : "; cin>>choice; switch(choice) { case 1: do { b.add_book(); cout<<" Do You want to Add more Book (y,n) : "; cin>>z; } while(z == 'y'); break; case 2: b.show_books(); break; case 3: b.update_book(); break; case 4: b.del_book(); break; case 5: exit(0); default: cout<<" Please Enter the correct button"; } getch(); goto p; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions