Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Select data structure and algorithm, and then describe the used dataset and then the obtained results For this code. bookstore.java Test.java import java.util.Scanner; public class

Select data structure and algorithm, and then describe the used dataset and then the obtained results For this code.

bookstore.java

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Test.java

import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int ch = 1; String isbn; String title; String authorName; int noOfPages; double price; int position; BookStore list = new BookStore(); while (ch != 7) { System.out.println(" ===================================MENU==================================="); System.out.printf("%-20s%-20s%-20s%-20s ", "1. Add First", "2. Add Last", "3. Add at Pos", "4. Remove"); System.out.printf("%-20s%-20s%-14s ", "5. Search", "6. Display", "7. Exit"); System.out.println("=========================================================================="); System.out.print("Enter your choice: "); ch = Integer.parseInt(sc.nextLine()); switch (ch) { case 1: System.out.print(" Enter ISBN number: "); isbn = sc.nextLine(); System.out.print("Enter book title: "); title = sc.nextLine(); System.out.print("Enter author name: "); authorName = sc.nextLine(); System.out.print("Enter number of pages: "); noOfPages = Integer.parseInt(sc.nextLine()); System.out.print("Enter price: "); price = Double.parseDouble(sc.nextLine());

list.addFirst(isbn, title, authorName, noOfPages, price); break; case 2: System.out.print(" Enter ISBN number: "); isbn = sc.nextLine(); System.out.print("Enter book title: "); title = sc.nextLine(); System.out.print("Enter author name: "); authorName = sc.nextLine(); System.out.print("Enter number of pages: "); noOfPages = Integer.parseInt(sc.nextLine()); System.out.print("Enter price: "); price = Double.parseDouble(sc.nextLine());

list.addLast(isbn, title, authorName, noOfPages, price); break; case 3: System.out.print("Enter position to insert: "); position = Integer.parseInt(sc.nextLine()); System.out.print(" Enter ISBN number: "); isbn = sc.nextLine(); System.out.print("Enter book title: "); title = sc.nextLine(); System.out.print("Enter author name: "); authorName = sc.nextLine(); System.out.print("Enter number of pages: "); noOfPages = Integer.parseInt(sc.nextLine()); System.out.print("Enter price: "); price = Double.parseDouble(sc.nextLine());

list.addAtIndex(position, isbn, title, authorName, noOfPages, price); break; case 4: System.out.print(" Enter book title to be removed: "); title = sc.nextLine(); list.remove(title); break; case 5: System.out.print(" Enter book title to search for: "); title = sc.nextLine(); list.search(title); break;

case 6: list.display(); break; case 7: System.out.println(" Thank you!"); break; default: System.out.println("Error: Invalid choice."); } } } }

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 Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions