Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODING IN JAVA Program Assignment 7 For this assignment, you will be making a book list program to support the following functions on a book

CODING IN JAVAimage text in transcribed

image text in transcribed

Program Assignment 7 For this assignment, you will be making a book list program to support the following functions on a book list: Insert new element at the end of the list Insert new element at a certain position Find an element (with its ISBN number and list its position) using linear search Find an element (with its ISBN number and list its position) of a sorted list using binary search Delete an element that is at a certain position Delete an element by using its ISBN number Sort the list by the ISBN numbers (using selection sort) Sort the list by the ISBN numbers (using bubble sort) Print out the list In your program, position 1 should correspond to the list element with index 0. Your program should begin with a loop asking the user what they want to do. Clearly, at the beginning since there is no list, they have to begin by inserting a new element at the first position. When calling the function to insert an element at a certain position, you have to check that the position is within bounds of the current book list. For your implementation, you can assume that the user will enter the ISBN number of the book (so you can use integers for your list). The function names should look something like the following: insert insert_at find_linear find_binary delete_item_position delete_item_isbn sort_list_selection sort_list_bubble print (1) Use array to write your program. Things to note when using array: 1. You can assume that you will not be buying more than 20 books. 2. When you insert or delete an element from an array at a certain position, you will have to shift the rest of the items on the list. You can use any algorithm you wish to do this. 3. For both insert and delete, you must check that you do not insert more than 20 items or delete from a list that has no items in it. 4. If there is more than one occurrence of an ISBN you can just delete the first one 5. For the binary search, you will need to check to see if the list is sorted already. If it is, binary search can be used. If it is not sorted yet, you will need to print out that the list needs to be sorted first before performing binary search. You can just use a variable to keep track of if the list has been sorted before using the binary search option. (2) Use ArrayList to write your program. The following is an example of what the program could look like. SAMPLE EXECUTION OF PROGRAM: : Welcome to the Book list program. . What would you like to do? 1. add an element to end of list 2. add an element at a location 3. find an element by ISBN number (linear search) 4. find an element by ISEN number (binary search) 5. delete an element at position 6. delete an element by ISBN number 7. 7 sort the list (using selection sort) 8. 8. sort the list (using bubble sort) 9. print the list 1. exit your choice - 1 Please type in the element 1454226834 Your list is now 1. 1454226834 What would you like to do? 2. add an element to end of list 3. add an element at a location 4. find an element by ISSN number (linear search) 5. find an element by ISBN number binary search) 6. delete an element at position 7. delete an element by ISEN number 8. sort the list (using selection sort) 9. sort the list (using bubble sort) 10. print the list 1. exit your choice - your 2 Please type in the element 2454326534 At what position? 1 Your list is now 1. 2454326534 2. 1454226834 What would you like to do? 2. add an element to end of list 3. add an element at a location find an element by ISBN number (linear search) 5. find an element by ISEN number binary search) 6. delete an element at position 7. delete an element by ISEN number 8. sort the list (using selection sort) 9. sort the 1.8t (using bubble sort) 10. print the list exit your choice - 6 Which element would you like to delete (by ISEN number)? () 1454226834 Your list is now 1. 2454326534 What would you like to do? 2. add an element to end of list 3. add an element at a location 4. find an element by ISBN number (linear search 5. find an element by ISBN number (binary search) 6. delete an element at position 7. delete an element by ISEN number 8. sort the list (using selection sort) 9. sort the list (using bubble sort) 10. print the list 0. exit your 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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions