#include int numBooks, yea; string titl, aut, pub, isb;

#include #include #include using namespace std;class book{    public:    string author;    string publisher;    string title;    int year;    string isbn;    book* next;    book(string, string, string, int, string, book*);};book::book(string tempTitle, string tempAuthor, string tempPublisher, int tempYear, string tempIsbn, book* tempNext){    title=tempTitle;    author=tempAuthor;    publisher=tempPublisher;    year=tempYear;    isbn=tempIsbn;    next=tempNext;}typedef book* bookPtr;void getline(istream &stream, string &str, char delimiter){    char temp500;    stream.get(temp, 500, delimiter);    stream.ignore(500, delimiter);    str = temp;}void getline(istream &stream, int &num, char delimiter){    int temp;    stream >> temp;    stream.ignore(500, delimiter);    num= temp;}void insert (bookPtr &root);void delTitle(bookPtr &root);void readFile(bookPtr &root);bookPtr locateNode(bookPtr temp, string titl);void delIsbn(bookPtr &root);bookPtr locateNodeIsbn(bookPtr temp, string isb);void printAuthor(bookPtr temp);void searchIsbn(bookPtr temp);void saveFile(bookPtr temp);void printList(bookPtr temp);int countNodes(bookPtr temp);void readFile(bookPtr &root){    int numBooks, yea;    string titl, aut, pub, isb;    ifstream infile (“books.txt”, ios::in);    infile >> numBooks;    infile.ignore(500,’
‘);    for (int count = 0; count < numBooks; count++)    {        getline(infile, titl, ' ');        getline(infile, aut, ' ');        getline(infile, pub, ' ');        getline(infile,yea, ' ');        getline(infile, isb, ' ');        root = new book (titl, aut, pub, yea, isb, root);    }}void insert (bookPtr &root){    string titl, aut, pub, isb;    int yea;    cout<<"Title: ";    cin.ignore(500,' ');    getline(cin, titl, ' ');    cout<<"Author: ";    getline(cin, aut, ' ');    cout<<"Publisher: ";    getline(cin,pub, ' ');    cout<<"Year: ";    getline(cin,yea, ' ');    cout<<"ISBN: ";    getline(cin, isb, ' ');    root = new book (titl, aut, pub, yea, isb, root);}void delTitle(bookPtr &root){    string titl;    cout << "Book Title: ";    cin.ignore(500,' ');    getline(cin, titl, ' ');    bookPtr p = locateNode(root, titl);    if (p == NULL)        cout << " Deletion cannot be done. ";    else if (root == p)        root = p->next;    else    {        bookPtr q = root;        while (q->next != p)            q = q->next;        q->next = p->next;    }    delete p;}bookPtr locateNode(bookPtr temp, string titl){    while (temp != NULL)    {        if (temp->title == titl)        {            return temp;        }        temp=temp->next;    }    return NULL;}void delIsbn(bookPtr &root){    string isb;    cout<<"Book ISBN: ";    cin.ignore(500,' ');    getline(cin, isb, ' ');    bookPtr p = locateNodeIsbn(root, isb);    if (p == NULL)        cout << " Deletion cannot be done. ";    else if (root == p)        root = p->next;    else    {        bookPtr q = root;        while (q->next != p)            q = q->next;        q->next = p->next;    }    delete p;}bookPtr locateNodeIsbn(bookPtr temp, string isb){    while (temp != NULL)    {        if (temp->isbn == isb)        {            return temp;        }        temp = temp->next;    }    return NULL;}void searchIsbn(bookPtr temp){    string isb;    cout << "Book ISBN: ";    cin.ignore(500,' ');    getline(cin, isb, ' ');    while (temp != NULL)    {        if (isb == temp->isbn)        {            cout<title << endl;            cout<author << endl;            cout<publisher << endl;            cout<year << endl;            cout<isbn << " ";        }        temp=temp->next;    }    cout<title << endl;        cout<author << endl;        cout<publisher << endl;        cout<year << endl;        cout<isbn << " ";        temp=temp->next;    }    cout << " ";}void printAuthor(bookPtr temp){    string aut;    cout << "Author name: ";    cin.ignore(500,' ');    getline(cin, aut, ' ');    while (temp != NULL)    {        if (temp->author == aut)        {            cout<title << endl;            cout<author << endl;            cout<publisher << endl;            cout<year << endl;            cout<isbn << endl;        }        temp=temp->next;    }    cout<title << endl;        outFile<author << endl;        outFile<publisher << endl;        outFile<year << endl;        outFile<isbn << endl;        temp=temp->next;    }    cout<next;    }    return countB;}int main(){    int choice;    bookPtr root = NULL;    readFile(root);    do    {        cout<<" PROJECT ON (L M S) ";        cout<<" MENU Choose your likely option !"<>choice;        if (1 <= choice && choice <= 6)        {            switch (choice)            {            case 1:                insert(root);                break;            case 2:                delTitle(root);                break;            case 3:                delIsbn(root);                break;            case 4:                searchIsbn(root);                break;            case 5:                printList(root);                break;            case 6:                printAuthor(root);                break;            default:                cout<<"Invalid selection so enter again. ";                break;            }        }    }    while (choice!=7);      saveFile(root);    return 0;}

x

Hi!
I'm Clifton!

Would you like to get a custom essay? How about receiving a customized one?

Check it out