Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project #7 Instructions 1. Create a structure that will hold Account Information and create an array of these structures: struct AccountInfo { long companyNumber; string

Project #7 Instructions 1. Create a structure that will hold Account Information and create an array of these structures: struct AccountInfo { long companyNumber; string companyName; }; AccountInfo accounts[20]; 2. Create an input file named accountInfo.txt that contains the following information which is made up of company account numbers and company names (be sure you test for a valid input file): 12345 West Seneca Widget Factory 23344 Buffalo Auto Parts 24567 Smith Brothers Supply 45337 Jones Industrial 25655 Sanborn Products 33557 Buffalo Belt Company 19988 Tonawanda Tires 3. You will use the same process to read from a file as you did in the previous project, but you will be reading data from the file and storing it in an array of structures so the syntax will look as follows because each element in the array holds two structure members: inFile >> accounts[count].companyNumber; inFile.ignore(); // takes out the end of line code before executing the getline getline(inFile, accounts[count].companyName); 4. Call a function named displayAccountInfo which will display a table that displays the company numbers and names: Company Number Company Name 12345 West Seneca Widget Factory 23344 Buffalo Auto Parts 24567 Smith Brothers Supply Etc If you are able to get the table to displays then you know everything is working properly with the input file and you can proceed with the rest of the program. 5. Sort the array by comanyNumber using the bubble sort and then display call the displayAccountInfo function again to see if the sort worked properly You can use the sort code provided in class, but be sure you change the data type of the array from int to AccountInfo in the function heading. Since you are sorting an array of structures, you need to only compare the companyNumbers in the array, so please note the following change to the sort: Bubble Sort (you just need to compare the companyNumber): if (array[count].companyNumber > array[count + 1].companyNumber) Selection Sort: You can also choose the selection sort if you wish, but it will require a few more modifications to handle an array of structures 6. At this point you call the displayAccountInfo twice, so take out the first call to this function so you will only display the table once and when it is displayed it will be sorted. 7. Next prompt the user to enter a company number and use this number as your search value (this variable should be a long data type) and call either the linear search or the binary search (which ever one your prefer) to search for this search value and display either That is a valid company if the company number is found in the array or That is not a valid company if the company number is not found in the array. You can use the search code provided in class, but be sure you change the data type of the array from int to AccountInfo in the function heading. Since you are searching an array of structures, you only need to look at the companyNumbers in the array, so please note the following changes to the search functions: Binary Search: if (array[middle].companyNumber == value) else if (array[middle].companyNumber > value) Linear Search: if (list[index].companyNumber == value) 8. Project Requirements: Your program should include appropriate comments at the top and prior to each function The table that displays should be neatly formatted and easy to read You should use functions as needed (storing data from file into array, sort, search, display table, etc.) and all parameters should be appropriate (value, reference, constant, constant reference)

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions