Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

C++ (Menu Design and Function Development Assignment)

flamenca91
flamenca91 


Project 3. Menu Design and Function Development Skills Assumptions: A. Basic decision Operations, B. Arithmetic Operations, C. Basic input/output operations cin, getline(),cin.get() and cout. D. User-defined function creation. I. Introduction In this project a "main menu" will be created to access various components of the program. All menu modules have four common characteristics: they display the program user options, prompt the user for input and accept the user response, check the user response for reasonableness, and finally execute the requested program sequence. Figure 6 presents a simplified hierarchy chart showing the relationship between the main menu and accessed routines. Data: 0.45 0.376 0.15 0.043 ___________________________________________________________________ Hierarchy Chart - levels 1 and 2 ___________________________________________________________________ A "level 1" pseudocode sequence for a two-option menu is presented in Figure 5. Note that all menus should include a "Quit" option (not shown). This option may be worded somewhat differently, however once established the message should be consistent through out the program. ___________________________________________________________________ do Display options Display "Quit" option Allow user input Error check for appropriateness and Call requested programming routine while the user input is not Quit Figure 5. Pseudocode for a two-option menu. ___________________________________________________________________ Note the display lines may be as many as necessary to display the required options. This is the only significant change required for various menus, and will make the routine available for use as a template with a minimum of modifications. Calling the requested routine can be accomplished typically by using a switch() structure which can make any number of comparisons. Error trapping is typically incorporated into the menu module by way of the default label within the switch() structure. The default option will be executed if there are no other matches made in the structure. The default option is typically used to display an error message and a prompt to continue the program. The menu continues to execute (loop) until the user enters the key for Quit, at which time the execution of the remainder of the program continues. It is now necessary to consider the concept of a module. Modules are programming units which essentially have "one way in and one way out" in addition they typically have one or a very limited number objectives. In C++ the programming construct for a module is the function or as it is sometimes known as a "user-defined function". Referring back to Figure 4, it can be surmised that there could be at least four modules in the program as it is currently conceived: A main menu, data input, and data display in addition to the screen title. To this we might add "sub-modules" or "level two" modules which would include utilities such as the Error Check screens, calculation modules, etc. that might be called from level 1 modules. The design of programming systems often begins with the development of an over all hierarchy chart that displays basic relationships between various sections of the project. Then typically pseudocode is used to identify the specific actions of each module, often identifying level 2 modules which may be needed, as well as processes which may be redundant between modules (processes which may be combined). The actual pseudocode is often left to the developer or programmer. However, once again consistency and understandability are the keys. Each module should have a separate pseudocode sequence. II. Scenario In that in the C++ programming language modules are developed using the "user-defined" function, the essence of this project is to develop a main menu function that will selectively call or access various other functions (modules) passing to them all required data. Data will be passed from main() into the mainMenu() and inputScreen() via referenced parameters. The second aspect of this project is to break the program sequence created in Project 2 into modules specifically a Title Screen Module, an Input module, and a Display module. The main menu module should be programmed as a separate module, after the modules indicated above have been created and validated. Figure 6 presents a hierarchy chart with the menu module as a separate module. _________________________________________________________________ _________________________________________________________________ III. Program Code for the Bookstore Order System The modules created in this project should be able to be used (with minor modification) in project 4. Separate the code from Project 2 into three modules: Title Screen, Data Input, and Data Output modules. Each module should be coded as a separate function. All data input should be entered into character strings (for ease of access and error checking). The user input in the menu should be a single character. Note that each module should have one way in, one way out, and limited objectives. IV. Output A. General Operation The program should display the "Title Screen" until the user presses a key to continue. The "Main Menu" should then be displayed with a prompt for user input. The menu should also display a "Quit" option. The menu screen should follow the specifications developed in Project 2. Subsequent to the option selection, the program should branch to the appropriate module. Each module display should also be consistent with Project 2 specifications. Upon user request, each module should return control to the Main Menu. All data should be entered as character strings and converted within the appropriate modules into a usable data types. B. Error Trapping Error trapping requirements are limited to the selection entered as a response to the menu selection prompts. C. Program Validation Operation of each program must be substantially demonstrated as to computational reliability. Each numeric computation should be tested with a variety of data. The selection of the data set should demonstrate the program's accuracy on the broadest range practical as well as with "critical" values such as 0, or range limits. This should be represented in the data sets chosen for the demonstration of the project. It is the programmer's responsibility to be prepared to adequately demonstrate all facets of the program. Attachments
Tags Clarifications

Answers