Starting from:

$20

Develop a program flowchart and then write a menu-driven C++ program Solved

Develop a program flowchart and then write a menu-driven C++ program that will solve the following problem. The menu is shown below. Note: the bold letters are used for emphasis and you do not have to make them bold in your program. This program uses array, random number generator, and functions, among other things. Help FillArray MinFreq MaxFreq Quit Upon program execution, the screen will be cleared and the menu shown above will appear at the top of the screen via a user-defined function menu(), and properly centered.

The user is then prompted to make a selection. The menu items are explained below. At the beginning, only options H, A, and Q will be available. Selecting options M or F will be flagged as error, and the user is warned to activate option A first. This means you need to set a boolean variable which handles this logic. H or h ( for Help ) option will invoke a function named help() which will display a help screen. The help screen(s) should guide the user how to interact with the program, type of data to be entered, and what results would the program produce. Each help screen should remain on the monitor until the user strikes any key (e.g., strike the space bar followed by a carriage return would do the job). Once the user strikes a key, the screen will be cleared and the menu is displayed again with another prompt. A or a( for FillArray ) option will prompt the user for the number of elements for the array which will be examined. This option also reads two other integers which provide the range of numbers, extracted from the random number generator function and used to initialize the array. Once this operation is completed, the user can select options M or F. This option is implemented in a function named FillArray() which takes an array as its argument (sized to 100 in main()) and passed to FillArray().

This function will have additional argument such as the Boolean flag, number of elements, etc. Once this operation is performed, control is returned to main(), screen will be cleared, and the menu is displayed again with another prompt. At this time, the array is initialized to exact number of elements in the specified range. Option A must be executed at least once before options M, or F can be executed. M or m ( for MinFreq ) option will find the minimum number in the array and its frequency of occurrence. It also uses the function named result(), with appropriate arguments which will display the original array, the minimum number and the frequency of occurrence of the minimum number in the array. There should be no changes to your code if the array was specified to have different size and/or different range. You may use the following format: Array Elements: (list the elements) Minimum number: XX (XX may be any integer number in the range) Frequency: YY (YY is an integer number) The results should remain on the screen with the following prompt, which will appear on the lower right hand corner of the screen: Strike any key to continue... Once the user entered a key, the screen will be cleared and the menu is displayed again and the user is prompted. F or f ( for MaxFreq ) option will find the maximum number in the array and its frequency of occurrence. It also uses the function named result(), with appropriate arguments which will display the original array, the maximum number and the frequency of occurrence of the maximum number in the array. There should be no changes to your code if the array was specified to have different size and/or different range.

You may use the following format: Array Elements: (list the elements) Maximum number: XX (XX may be any integer number in the range) Frequency: YY (YY is an integer number) The results should remain on the screen with the following prompt, which will appear on the lower right hand corner of the screen: Strike any key to continue... Once the user entered a key, the screen will be cleared and the menu is displayed again and the user is prompted. Q or q (for Quit) option will clear the screen and returns the control to the Visual Studio IDE. Sample Data to be used are shown below. Of course, your program will work with any set within the specified range of elements. Test your program with the following data: Array size is 5 and the range is -25 to +25 Array size is 3 and the range is -2 to +2 Array size is 8 and the range is 20 to 100 Random number generations

You may use the following generalized formula to generate random numbers, once you have set the seed through srand() function call as in: int seed, cin seed; // with proper prompt to read from keyboard, a large, prime number srand(seed); // gets the generator going through successive calls to rand() function. The generalized formula can be written as: rand() % ((max + 1) – min) + min To generate numbers between 20 and 30 inclusive, the formula will reduce to: rand() % (( 30 + 1 ) – 20) + 20 = rand() % 11 + 20 You may also use srand(time(NULL)); to get the seed based on the machine time by including header file.

More products