Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this project, you will implement the following four functions, using the exact function names, parameter types, and return types shown in this specification. (The
For this project, you will implement the following four functions, using the exact function names, parameter types, and return types shown in this specification. (The parameter names may be different if you wish). This function returns true if its parameter is a well-formed order string, and false otherwise. If the parameter is a well-formed order string, the function should read each order and return the total cost for all the orders requested. Invalid order strings should return a cost of 1.00 int howManyCombos(string orders, If the string parameter is a well-formed order string, the function should count up how many of the particular ordered combo has been requested. The only valid values for the int parameter is the number 1,2 or 3 . Any other int parameter value should result in a count of 1. If the order string is itself not a well-formed order string, return 1. int howManyShakes(string orders, string whichShake) If the string parameter is a well-formed order string, the function should count up how many of the particular ordered shake has been requested. The only valid values for the whichShake parameter are "Chocolate", "Vanilla" or "Strawberry". Any other whichShake value should result in a count of -1. If the order string is not a well-formed order string, return 1. Based on their menu, I'd like you to process a customer order and determine its cost. Each order is made up of a quantity and an item . For example, " 4:1 " means move 4 combo1's (that is, four double-double burgers). An order string might hold multiple orders inside it. Due to their limited oven space, In-N-Out limits walkup orders to no more than 50 burgers items of any kind. The quantity field will be an integer amount. A quantity cannot be zero, negative or greater than nine hundred ninety nine. The item field will be either 1 (for a double-double), 2 (for a cheeseburger), 3 (for a hamburger), C (for chocolate shake), V (for vanilla shake) or S (for strawberry shake). Quantities and item numbers must be separated by a colon (:). Additional quantities and item values will be separated by an underscore (_). All of the following are examples of valid order strings: - 4:1 (an order of 4 double-doubles) - 2:1_2:1 (again an order of 4 double-doubles) - 2:2_2:1 (an order of 2 double-doubles and 2 cheeseburgers) - 2:1_1:C (an order of 2 double-doubles and a chocolate shake) All of the following are examples of invalid order strings: - 4:5 (unsupported items) - +4:1 (unsupported characters in the order) - 1:1_2:2_o:3 (zero is not supported) - 1:1_-12:2 (negative quantity is not supported) - 500:1_500:2 (more than 50 items of any kind is not supported) - 40:1_10:1_1:1 (more than 50 items of any kind is not supported) - 40:1_10:2_1:3 (more than 50 items of any kind is not supported) - 1:1_2 (missing a quantity - don't assume 1 ) Double-Double's (combo 1) cost $9.45 each. Cheeseburgers (combo 2) cost $7.95 each. Hamburgers (combo 3 ) cost $7.55 each. Shakes cost $2.85 each. Based on these prices: - 4:1 costs $37.80 - 2:1_2:1 costs $37.80 - 2:2_2:1 costs $34.80 Precisely, to be a valid order string, the string - can contain only the uppercase letters C, V, S as well as digit characters o, 1, 2, 3, 4, 5, 6, 7, 8 and 9 and the characters : and _ - must start with digits(s) - a groups of digits must be separated by : and then followed by either 1,2,3,C,V or S - additional groups of digits separated by : and then followed by either 1,2,3,C,V or S must be preceded with a - - no extra or unused characters once the digit groups are fully processed - no more than 50 items of any kind - no negative or zero quantities - no extra leading zeros in any number quantities All of the following are examples of valid order strings: - 1:1_1:2_1:3_1:C_1:S_1:V (one of each menu item) - 10:1 (ten combo 1 's) - 1:1_5:1_4:1 (ten combo 1's) All of the following are examples of invalid order strings: - xyz (bad characters) - 1:c (lowercase letters not supported) - 1:1 zzz (to be valid, all characters must be consumed. the extra characters at the end will make this string invalid) - 100:1 (morethan 50 items or more total) - 10:1_20:1_30:2 (more 50 items or more total) - 40:1_10:2_1:3 ( 5 o items or more total). - 40:C_10:V_1:S (morethan 5 items or more total). - 40:1_10:2 (50 items or more total). - 40:C_10:V .50 items or more total). - 40:C (spaces anywhere are not allowed)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started