174k views
0 votes
There must be at least one value-returning function to determine the type and price for the sandwich, the type and price of the side order, and the type, size, and price for the drink. here is how such a function should work: o the function should prompt the user to input the item in question (sandwich, side order, or drink), then verify the entry is valid by using a loop, and then determine the correct name and price of the item. o for the sandwich and the side order, have the user enter a number for what they want. for example, you can have the user select a sandwich by entering 1 for a hamburger, 2 for cheeseburger, 3 for a

What should the user input to select a sandwich?
A. 1
B. A
C. Sandwich
D. Hamburger

1 Answer

2 votes

Final answer:

To select a sandwich when prompted by the function, the user should input a numerical value such as 1, which might correspond to a specific type of sandwich like a hamburger.

Step-by-step explanation:

To select a sandwich, the user should input a number corresponding to the type of sandwich they want. According to the instructions given, the user is prompted with a menu where a number (1, 2, 3, etc.) represents a specific type of sandwich. For instance, if they enter 1, they may be selecting a hamburger. Therefore, to choose a sandwich, users utilize numerical inputs rather than textual descriptions of the sandwich like 'Hamburger' or 'Sandwich'.

This approach of using numerical selection falls under basic programming concepts where input validation and user input handling are key features. Establishing such functionality requires understanding the ability to represent the value of an item and applying loops for input validation within functions in programming. It ensures that the user's choice corresponds to a valid option from the menu provided, thus determining the correct name and price of the item efficiently.

User Elias Soares
by
8.4k points