Computer Science 1026A/B Lecture Notes - Lecture 4: Specialty Coffee

234 views3 pages
##
#This program comptutes the cost of a specialty coffee or tea beverage.
#
#Obtain customer's name, type of beverage, size of beverage, and added flavorings
userInput = input("Please enter your name ")
customerName = userInput
if customerName.isalpha():
userInput = input("Please enter your type of beverage which can be coffee or tea.
")
beverageType = userInput
TEA_TYPE_LIST = ["tea","t"]
COFFEE_TYPE_LIST = ["coffee","c",]
if beverageType.casefold() in TEA_TYPE_LIST:
userInput = input("Please enter the size of your beverage which can be small,
medium, or large. ")
beverageSize = userInput
BEVERAGE_SIZE_LIST = ["s","small","m","medium","l","large"]
elif beverageType.casefold() in COFFEE_TYPE_LIST:
userInput = input("Please enter the size of your beverage which can be small,
medium, or large. ")
beverageSize = userInput
BEVERAGE_SIZE_LIST = ["s","small","m","medium","l","large"]
else:
exit()
else:
print("Please don't enter any numbers or spaces")
exit()
if beverageSize.casefold() in BEVERAGE_SIZE_LIST:
if beverageType.casefold() in TEA_TYPE_LIST:
userInput = input("Please enter your added flavour which can be mint, lemon, or
none. ")
teaAddedFlavoring = userInput
TEA_FLAVOR_LIST = ["m","mint","lemon","l","none",""]
if teaAddedFlavoring.casefold() in TEA_FLAVOR_LIST or
teaAddedFlavoring.isspace() in TEA_FLAVOR_LIST:
SMALL_NAMES = ["small","s"]
MEDIUM_NAMES = ["medium","m"]
LARGE_NAMES = ["large","l"]
if beverageSize.casefold() in SMALL_NAMES:
beverageSizeCost = 1.50
elif beverageSize.casefold() in MEDIUM_NAMES:
beverageSizeCost = 2.50
elif beverageSize.casefold() in LARGE_NAMES:
beverageSizeCost = 3.50
NONE_NAMES = ["none",""]
MINT_NAMES = ["m","mint"]
LEMON_NAMES = ["l","lemon"]
if teaAddedFlavoring.casefold() in MINT_NAMES:
beverageFlavoringCost = 0.50
flavoringName = "with mint"
elif teaAddedFlavoring.casefold() in LEMON_NAMES:
beverageFlavoringCost = 0.25
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents

Document Summary

#this program comptutes the cost of a specialty coffee or tea beverage. Coffee_type_list = ["coffee","c",] if beveragetype. casefold() in tea_type_list: userinput = input("please enter the size of your beverage which can be small, medium, or large. ") beveragesize = userinput. Beverage_size_list = ["s","small","m","medium","l","large"] elif beveragetype. casefold() in coffee_type_list: userinput = input("please enter the size of your beverage which can be small, medium, or large. ") beveragesize = userinput. Tea_flavor_list = ["m","mint","lemon","l","none",""] if teaaddedflavoring. casefold() in tea_flavor_list or teaaddedflavoring. isspace() in tea_flavor_list: Lemon_names = ["l","lemon"] if teaaddedflavoring. casefold() in mint_names: beverageflavoringcost = 0. 50 flavoringname = "with mint" elif teaaddedflavoring. casefold() in lemon_names: beverageflavoringcost = 0. 25 flavoringname = "with lemon" elif teaaddedflavoring. casefold() in none_names: beverageflavoringcost = 0 flavoringname = "no flavoring" 2)) + ". ") import os os. system("pause") else: exit() if beveragetype. casefold() in coffee_type_list: userinput = input("please enter your added flavour which can be chocolate, vanilla, maple, or none. ") coffeeaddedflavoring = userinput. Coffee_flavor_list = ["m","maple","chocolate","c","vanilla","v","none",""] if coffeeaddedflavoring. casefold() in coffee_flavor_list or coffeeaddedflavoring. isspace():

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions