$18.99
The objective of this lab task is to provide you with the experience in writing codes using searching and sorting algorithms.
TASKS:
Suppose you have a list of customers for a local supplier company. Each customer is known with their customer id (an integer value in the range between 1 and 999), first name (a cstring with a maximum of 50 characters), last name (same as first name), and contact number (a cstring with a maximum of 20 characters). You are required to write a program that will allow you to read this list from a binary file and perform a search on this list to locate a particular customer’s information by asking the user to enter the customer’s id.
Your program should prompt the user for a filename. The file cust.dat is provided to you containing a list of unsorted customers to be used in this lab task. Read all the records into an array of suitable data structure. You need to determine the number of records available and use this information to dynamically allocate the array.
The records are not sorted. Therefore, you are required to first sort the records in the array according to the customer id in ascending order. You are required to use an insertion sort algorithm to perform this. Once the records have been sorted, allow the user to perform a search on the sorted list to locate a customer by prompting the customer id. For this task, you are required to perform a binary search on the list of records you have. If the record is found, display the details on standard output. Otherwise, display a message indicating that the record is not found. In either case, allow the user to continue searching for another record until a quit option is entered.