Assignment Overview

This assignment will give you experience on the use of defining and calling functions.

Program Description

Modify the barista program to use functions. Your program must include functions that do the following:

  • Get customer order: Take and validate the user's coffee request. As a reminder, options include 'Long Black', 'Flat White', 'Latte', or 'Short Black'. The function should return a valid coffee type.
  • Get extras: Take the user's coffee request as an argument and return either 'No Extras or Milk on the Side based on the coffee type. For requests that are either a long or short black, your function will ask the customer if they want milk on the side, validate the response and return the appropriate value. For latte and flat white, the function will return No Extras.
  • Get here or to go: Ask the customer if they would like their order to go, validate the response and return either "In caf" or To go
  • Get and validate yes/no questions: Takes a prompt for a yes-no question and returns either Y or N. This function should loop until the user provides a correct response. It should be called from the two functions above.

Assignment Notes:

The main part of your program will call each of the first three functions and save the return value for each. The function calls will be followed by print statements that print the customer's order.

Sample Interactions:

This should look identical to your output for the original barista program.

Welcome to my Coffee Shop
We serve Long Black, Flat White, Latte, Short Black
What would you like? Long Black
Do you want milk on the side (Y/N)? Y
Would you like your order to go (Y/N)? n
Would you like your order to go (Y/N)? N

Long Black
Milk on the side
In cafe
Welcome to my Coffee Shop
We serve Long Black, Flat White, Latte, Short Black
What would you like? Latte
Do you want milk on the side (Y/N)? Y

Latte
No extras
To go
Welcome to my Coffee Shop
We serve Long Black, Flat White, Latte, Short Black
What would you like? Coffee
Can you please try again? Long Black
Do you want milk on the side (Y/N)? yes
Do you want milk on the side (Y/N)? No
Do you want milk on the side (Y/N)? N
Would you like your order to go (Y/N)? No
Would you like your order to go (Y/N)? N

Long Black
No extras
In cafe
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.