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

You will implement a simple library catalog system in which a user can search fo

ID: 3739487 • Letter: Y

Question

You will implement a simple library catalog system in which a user can search for a book with respect to Book Title or ISBN Number. Also the administrator of the system could add a book record, delete a book record, or update book information. Step 1 Each record has three fields: -Book Title, - Author Name -ISBN Number We assume that fixed-length record size is used. So we may represent the record as the following data structure in C++: typedef struct TBook ! char author 16] char title[24] char isbn 10] char *keyOreturn isbn; SBook; Step 2 Implement add, delete, and update functions. Make sure that you consider the following situations in your design - When you add a record, first look at the AVAIL LIST, then write the record. If there is a record available in the AVAIL LIST, write the record to a record AVAIL LIST points and make appropriate changes on the AVAIL LIST - If the record to be added already exits, do not write that record to the file - When you delete a record, do not physically delete the record from file, just put a marker on the file and make appropriate changes on AVAIL LIST If the record to be deleted does not exist, display a warning message on the screen -The file should be compact after exiting the program, ie. there should be no records marked as deleted in the file Step 3 Implement two sorted lists, one for isbn and one for book title. Keep the lists sorted after add and delete operations. Step 4 Implement searching on Book Title and ISBN Number

Explanation / Answer

Implemented it in C++. Added few functions like add/update/disaply all books. You can add Remaining functions.

# include <iostream>

#include <vector>

using namespace std;

struct TBook

{ string author;

string title;

string isbn;

string available;

string key() { return isbn;};

};

class Library {

vector<TBook> books;

public:

void menu(int*);

void add() {

struct TBook newBook;

cout<<"Enter book details[author, title, isbn]:"<<endl;

getline (cin, newBook.author);

getline (cin, newBook.title);

getline (cin, newBook.isbn);

books.push_back(newBook);

}

void PrintAllBooks() {

vector <TBook> :: iterator i;

for (i = books.begin(); i != books.end(); ++i) {

cout<<"Book Title: "<<i->title<<endl;

cout<<"Author name: "<<i->author<<endl;

cout<<"ISBN:"<<i->isbn<<endl;

cout<<"---------"<<endl;

}

}

void update() {

string title, author;

vector <TBook> :: iterator i;

cout<<"Enter author name and title to update"<<endl;

getline (cin, author);

getline (cin, title);

for (i = books.begin(); i != books.end(); ++i) {

if (author == i->author) {

cout<<"Before update title:"<<i->title<<endl;

i->title = title;

cout<<"After title update:"<<i->title<<endl;

}

}

}

void searchBook() {

string author;

vector <TBook> :: iterator i;

cout<<"Enter author name to search Books"<<endl;

getline (cin, author);

for (i = books.begin(); i != books.end(); ++i) {

cout<<i->author<<author<<endl;

if ((author == i->author) || (author.compare(i->author) == 0)) {

cout<<"Book Title: "<<i->title<<endl;

cout<<"Author name: "<<i->author<<endl;

cout<<"ISBN:"<<i->isbn<<endl;

cout<<"---------"<<endl;

}

}

}

void sortBooks() { // sort the accounts using the account numbers

cout<<"Sort acc, need to impelement"<<endl;

}

void deleteBook() {

cout<<"Delete account, need to implement"<<endl;

}

};

/*===============function_file.cpp================================================*/

void menu(int *num) {

int select = 0;

string input;

cout << "Welcome! Select options below:" << endl;

cout << " 1. Add book." << " 2. Print all books." << " 3. Update book."<< " 4. sort books."<< " 5. Delete book." << " 6. search Book." << " 7. Quit"<<endl;

cout << "Selection: ";

getline (cin, input);

select = stoi(input);

*num = select;

// cout << " Selected option:" << select<<endl;

}

/*========================================================================*/

int main() {

// declare list of account here. The size of the list is not fixed.

class Library lib;

int input = 0;

// run loop to continue program until terminated by user

while (input != 6) {

menu(&input);  

switch (input) { // cases: call functions to perform tasks

case 1: lib.add(); break;

case 2: lib.PrintAllBooks(); break;

case 3: lib.update(); break;

case 4: lib.sortBooks(); break;

case 5: lib.deleteBook(); break;

case 6: lib.searchBook(); break;

case 7: /* Quit */ break;

default: input = 7; break;

}

}

return 0;

}

Input:

1
raj
"Algorithm Introduction"
12345
1
shekar
ram
12346
2
3
raj
maths
2

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote