Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CONVERT INTO JAVA CODE, DONT USE ANY BUILT IN DATA SCRTUTURE LIBRARY CONVERT AS IT IS /* * Book Store Implementation */ #include #include #include

CONVERT INTO JAVA CODE, DONT USE ANY BUILT IN DATA SCRTUTURE LIBRARY CONVERT AS IT IS

/* * Book Store Implementation */ #include #include #include /* * Node Declaration */ using namespace std; struct node { string book_name; string author; struct node *next; struct node *prev; }*start; class book_store { public: void addBook(string book_name, string author); //void delete_element(int value); //void search(string name); void display(); void search(string book_name); void remove(string name); void countBooks(); book_store() { start = NULL; } }; int main() { int choice; string name; string author; book_store b; while (1) { cout<>choice; switch ( choice ) { case 1: cin.ignore(80, ' '); cout<<"Name of the Book : "; cin>>name; cin.ignore(80, ' '); cout<<"Author of the Book : "; cin>>author; b.addBook(name, author); cout<>name; b.remove(name); break; case 3: b.countBooks(); break; case 4: cin.ignore(80, ' '); cout<<"Name of the Book you want to search: "; cin>>name; b.search(name); break; case 5: b.display(); break; case 8: exit(1); default: cout<<"Wrong choice"<book_name=book_name; temp->author=author; temp->next = NULL; if (start == NULL) { temp->prev = NULL; start = temp; } else { s = start; while (s->next != NULL) s = s->next; s->next = temp; temp->prev = s; } } void book_store::remove(string name) { struct node *tmp, *q; if (start->book_name == name) { tmp = start; start = start->next; start->prev = NULL; cout<<"Book Removed."<next->next != NULL) { if (q->next->book_name == name) { tmp = q->next; q->next = tmp->next; tmp->next->prev = q; cout<<"Book Removed."<next; } if (q->next->book_name == name) { tmp = q->next; free(tmp); q->next = NULL; cout<<"Book Removed."<book_name<<" \t Author Name: "<< q->author<next; } } void book_store::countBooks() { struct node *q = start; int cnt = 0; while (q != NULL) { q = q->next; cnt++; } cout<<"Number of Books in Book Store: "<book_name==name) { cout<<"Book is present in Book Store"<next; } } }

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 Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago