Question: A C-String is defined as a char array with a terminating null character. Write a method called promptForInput that will help you write user menus.
A C-String is defined as a char array with a terminating null character.
Write a method called "promptForInput" that will help you write user menus.
A Menu is a list of options for a user to select. The selection is the single character chosen for a menu item.
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.
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 characters.
I.E.
char menu[] = "1. Buy 2. Sell 3. Convert X. Exit";
Assignment Menu
1. Buy
2. Sell
3. Convert X. 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 coded. 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. 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
