C++ Program: A menu is a list of options for a user to select. The selection is the single character chosen for a menu item. An example menu is below: 1. Buy2. Sell3. Convert X. Exit Assignment: Write a method called "promptForInput" that will help you write user menus. You should be able to use this in future programs if wanted. The purpose for this method is to be the "end all of methods" that you could reuse in other situations. The code should pass an C-String of valid characters to select to the promptForInput method as the 1st parameter. See "C-Strings Stored in Arrays" on page 556 8th ed. or 566 9th ed. In the example above, the C-String would be "123X". The code should pass a C-String that is the menu to display as the 2nd parameter. It may help your display to have embedded \n characters.I.E. char menu[] = "1. Buy\n2. Sell\n3. Convert\nX. Exit"; Example pseudo code: define c-string char array of valid input characters define menu loop until X input char input = promptForInput( myValidCharArray, menu); ..... Your method needs to handle upper and lower case input as the same values, but returning the value in the case as given in the valid character list. Using the data above, if I entered 'x', it should return 'X. If a character is entered that is not in your list of valid characters - display and indicate that the input was invalid and redisplay the menu. This processing needs to be part of the promprForInput() method. The main method must call the promptForInput method and display the char returned from the promptForInput method. That is all that main() needs to do. The promptForInput() method menu needs to be able to process any number of characters. The promptForInput() method should not have hard coded processing - i.e. if == 'X' ... Depending on your compiler, you may or may not need one or both of the following: #include #include The assignment needs to call this method and report what valid character was given. The program should loop until the Exit option is selected. Deliverable - Write a program that displays the multi-choice menu (shown above in bold) that uses your new method to validate input. CPP program only.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
C++ Program:
A menu is a list of options for a user to select. The selection is the single character chosen for a menu item. An example menu is below:
1. Buy2. Sell3. Convert
X. Exit
Assignment:
Write a method called "promptForInput" that will help you write user menus. You should be able to use this in future programs if wanted. The purpose for this method is to be the "end all of methods" that you could reuse in other situations.
The code should pass an C-String of valid characters to select to the promptForInput method as the 1st parameter. See "C-Strings Stored in Arrays" on page 556 8th ed. or 566 9th ed. In the example above, the C-String would be "123X".
The code should pass a C-String that is the menu to display as the 2nd parameter. It may help your display to have embedded \n characters.I.E. char menu[] = "1. Buy\n2. Sell\n3. Convert\nX. Exit";
Example pseudo code:
define c-string char array of valid input characters
define menu
loop until X input
char input = promptForInput( myValidCharArray, menu);
.....
Your method needs to handle upper and lower case input as the same values, but returning the value in the case as given in the valid character list. Using the data above, if I entered 'x', it should return 'X.
If a character is entered that is not in your list of valid characters - display and indicate that the input was invalid and redisplay the menu. This processing needs to be part of the promprForInput() method.
The main method must call the promptForInput method and display the char returned from the promptForInput method. That is all that main() needs to do. The promptForInput() method menu needs to be able to process any number of characters. The promptForInput() method should not have hard coded processing - i.e. if == 'X' ...
Depending on your compiler, you may or may not need one or both of the following:
#include <cstring>
#include <string>
The assignment needs to call this method and report what valid character was given. The program should loop until the Exit option is selected.
Deliverable - Write a program that displays the multi-choice menu (shown above in bold) that uses your new method to validate input.
CPP program only.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images