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

(C++)In this assignment you will create a program that allows the user to choose

ID: 3770255 • Letter: #

Question

(C++)In this assignment you will create a program that allows the user to choose between the following menu choices (menu-driven program):

1. Linear Search

2. Binary Search

3. Bubble Sort

4. Selection Sort

5. Quit Keep running the program till the user chooses to Quit.

Your program should have the following parts: Searching Algorithms (Linear and Binary Search) You are the owner of a bookstore. You have the following information available in your stock (information is stored in the form of parallel arrays)

string bookTitle[] = {“Starting out with C++”, “Java Programming”, “Software Structures”, “Design and Analysis of Algorithms”, “Computer Graphics”, “Artificial Intelligence: A Modern Approach”, “Probability and Statistics”, “Cognitive Science”, “Modern Information Retrieval”, “Speech and Language Processing”};

int bookID[] = {1101, 1211, 1333, 1456, 1567, 1642, 1699, 1755, 1800, 1999};

double bookPrice[] = {112.32, 73.25, 54.00, 67.32, 135.00, 173.22, 120.00, 42.25, 32.11, 123.75};

First display() the above information to the user in a tabular format. Your program should then accept the book ID and the number of books the user wishes to purchase. Based on the book ID provided by the user, display the following information (if the ID is found):

o Book ID

o Book Title

o Number of books bought

o Total cost of the purchase If the book ID is not found, display a message saying so. The book ID needs to be searched based on linearSearch() or binarySearch() (based on user choice from the menu).

Sorting Algorithms (Bubble and Selection Sort)

Your program should generate 1000 random numbers in the range of 1 to 500 and store them in an array. Use bubbleSort() or selectionSort() (based on the menu choice) to sort the array of numbers. Display both the unsorted and the sorted array.

Instructions: Please make sure your code has following functions:

• display(): To display the contents of parallel array in a tabular format

• linearSearch(): To apply the linear search algorithm to search for the book ID

• binarySearch(): To apply the binary search algorithm to search for the book ID • bubbleSort(): To apply the bubble sort algorithm to sort the elements of an unsorted array

• selectionSort(): To apply the selection sort algorithm to sort the elements of an unsorted array You can use additional functions (optional) for other operations. Make sure your program runs till the user decides to quit the program. Your program should validate (input validation) the menu choice entered by the user.

Sample Output:
**** SEARCHING & SORTING MENU ****

Linear Search

Binary Search

Bubble Sort

Selection Sort

Quit

Please enter your choice: 1

**** LINEAR SEARCH *****

Book 1101 1211 ...

...
ID Title Cost Starting out with C++ $112.32 Java Programming $73.25 ... ... ... ...

Please enter the book ID you wish to purchase: 1101 How many copies you wish to purchase: 2 Book ID: 1101 Book Title: Starting out with C++ Number of books bought: 2 Total Cost: $ 224.64

The output will look the same for Binary Search too.

**** SEARCHING & SORTING MENU ****

1. Linear Search 2. Binary Search 3. Bubble Sort 4. Selection Sort 5. Quit Please enter your choice: 3

**** BUBBLE SORT ****

Unsorted array:

23 45 321 1 87 122 500 222 45 455 321 387 .............

Sorted array:

1 23 45 45 87 122 222 321 321 387 455 500 .............

Explanation / Answer

Sample code: