In this lab you will be coding a program that will make use of functions to search and sort an array. There will also be a print method, again complete with a full menu system. The Menu options are listed below in the section labeled “menu.”
You will need to set up a hundred (100) position integer (int) array that is defined globally. You will also need a global integer (int) variable called size. By doing this, you will not have to pass the Array and the size to each method you write. If you do not declare these variables globally, then they will have to be passed back and forth through your methods. Pick one method or the other. Do NOT do both (IE declare them globally and still pass them back and forth.)
Note: A Sample main method is provided at the bottom of this document. Yours may look slightly different than the one provided.
Menu:
The menu should have the following eight options:
1. Set the size of the array
2. Fill the array with random numbers (1 – 100)
3. Print the array
4. Sort the array in ascending sequence
5. Sort the array in descending sequence
6. Sequential search of the array for a
7. Binary search of the array for a target
8. Exit (this can be option zero if you prefer)
From these eight Options, one can see that seven methods will be needed. Each of the seven main functionalities above will need a function that does what they say.
Set size will change the global size value so that the user can pick how many values they want to use. This number cannot go beyond 100 (since 100 is the max size of the array)
When printing the array, it is required to print the position number alongside the value. Please start your positions at zero, and not one.
When doing the sorting methods, please use two different sorting algorithms. (IE, use a Min Max sort for ascending and an enhanced bubble for descending.)
For the Searching methods: you should ask for the target (number the user is searching for) in the dispatch method. Then pass the target to the search method. The search method should return the position it was found at (0 – Size) OR -1 if it was not found. Then have the appropriate messages print inside of the dispatch method.
You could write another function that does this part if you wish to keep your dispatch method cleaner and more organized. But that is up to you.
The running steps for this program are more ‘extensive’ then they have been in previous labs. Please follow the steps closely, and use the values specified. The numbers in (parenthesis) are the options if you set up your menu in the order listed above.
You will need to turn in your source code printed from Visual Studio, as well as your runs as described above. Staple them in that order.