• Make Order

  • order processing

  • Approve and Get
    your Order
Order Now

Menu based program

Write a menu based program implementing the following functions:

(0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user’s menu choice. Your program’s main function should only comprise of the following:

a do/while loop with the displayMenu function call inside the loop body
switch/case, or if/else if/ … for handling the calls of the functions based on the menu choice selected in displayMenu.
the do/while loop should always continue as long as the user does not choose to quit the program.
(1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type.

Have the program prompt the user to enter the number of rows and the number of columns for the two dimensional array.

Have the program prompt the user to enter the values for each row and column element in the two dimensional array.

Write the two dimensional array out as a text file. You will want the file format to be as follows:

First line contain the string: “UNSORTED”
The first two values stored in the file is the number of rows and the number of columns.
The remaining data is to be the two dimensional array being stored as long double typed values.
(2) Write a function like function #1, except this time, instead of asking the user for the values for each row and column element, have the function create a randomly generated values for the number of rows and columns (a minimum of 2 rows and a minimum of 2 columns, and a maximum of 10 rows and a maximum of 10 columns). Have the function that prompt the user for the name of a file to output as a text file the randomly generated values of type long double between the numbers 0 and 1, including fractional values in between such as (0.54734824682, etc).

Hint: you may want to have your program generate two random numbers and divide the smaller of the two random numbers into the larger random number.

You will want the file format to be as follows:

First line contain the string: “UNSORTED”
The first two values stored in the file is the number of rows and the number of columns.
The remaining data is to be the two dimensional array being stored as long double typed values.
(3) Write a function to prompt the user for the name of a file to input as a text file to read in the two dimensional array of long double type.

Output the contents of the two dimensional array to the screen.

(4) Write a function to prompt the user for the name of a file to input as a text file to read in the two dimensional array of the long double type and another filename for the name of the output file that will be outputting the two dimensional array after it has been sorted.

Load in the data from the original text file and ask the user which column would they like to sort by utilizing bubble sort.

Sort the two dimensional array based on the column the user specifies and by the sort order the user would like to sort (prompt the user, asking if they would like to sort the column from smallest to largest, or largest to smallest), and output the sorted two dimensional array to the output filename.

You will want the file format of the output sorted file to be as follows:

First line contain the string: “SORTED”
The first two values stored in the file is the number of rows and the number of columns.
Sorted Column (this is the column number of the sorted column)
Sort Order (this is a flag for what order is the sorted column sorted by)
The remaining data is to be the two dimensional array being stored as long double typed values.
(5)  Write a function to prompt the user for the name of a text file to read in the two dimensional array of long double data type.

Load in the data for the two dimensional array.

Prompt the user to enter the column they wish to search by (check to make sure the file is “marked” as “SORTED” – if the file is marked as “UNSORTED” do not allow a binary search to be done, but rather in this case, utilize linear search), and the value to find. Implement the binary search algorithm to find the value (remember, the column they specify must be sorted or binary search may not always work). You will have to come up with some technique to be able to determine if the user has the column sorted in smallest to largest, or largest to smallest sort order in order to use binary search correctly (the algorithm in class only works for sorted data that is sorted from smallest to largest).

Do data validation in all areas of your program as you see fit. I will try to break your programs!

Submit one zip file containing the source file and the flowcharts for all of functions, and main function with the menu in .pdf file format (I will not accept flowcharts in any other format).

To be submitted:

Pseudocode
Flowchart of your program design using draw.io (Export as PDF, JPeg or PNG format only).
C++ source code file (.cpp file) of your program. You program must demonstrate knowledge of topics covered between chapters 2 and 8 ( named constants, iomanip manipulators, sequential statements, decision statements, loop statements, functions, file I/O, and algorithms).

Both comments and pings are currently closed.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes