Question

This program will simulate buying a cup of coffee. The initial cost of a cup of...

This program will simulate buying a cup of coffee. The initial cost of a cup of coffee will be $2.00 (without adding items). This program will demonstrate a concept called parallel arrays. Parallel arrays are arrays that have the same number of items. For Python we will use lists. You will have a list that holds addingitems which will consist of a list equal to Cream, Caramel, Whiskey, Chocolate, Cinnamon and Vanilla. You will then have a parallel list of addingcosts equal to .89, .25, .59, 1.50, and 1.75. Notice each list has 5 items. .89 corresponds with Cream, .25 corresponds with Caramel, etc… You will use a loop and ask the user to enter addingitems or “XXX” to quit. If they enter addingitems that are in the addingitems list you will add the corresponding addingcosts to the order total. If the addingitems does not exist you will display a message that says, “Sorry, the add in items does not exist.” Once the user enters “XXX” the program ends and the order total is displayed. Make sure you are using proper function such as main() and some sort of function to add up your items.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

addingItems = ["Cream", 'Caramel', 'Whiskey', 'Chocolate', 'Cinnamon']

addingCosts = [0.89, 0.25, 0.59, 1.50, 1.75]

orderList = []

totalCost = 0

print("\n")

while True:

itemName = raw_input('Enter the item name: ')

if itemName == "XXX":

print("\nALL ORDERS\n" + str(orderList) + "\n")

print("Total Price: ${}".format(totalCost))

break

elif itemName not in addingItems:

print("Sorry, the add in item does not exist.")

else:

index = addingItems.index(itemName)

orderList.append(itemName + ": $" + str(addingCosts[index]))

totalCost += addingCosts[index]

************************************************************* SCREENSHOT **************************************************************

Add a comment
Know the answer?
Add Answer to:
This program will simulate buying a cup of coffee. The initial cost of a cup of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 5 5 - Parallel Arrays in Python Mind Tap - Cengage Lea x + V A...

    5 5 - Parallel Arrays in Python Mind Tap - Cengage Lea x + V A https//ng.cengage.com/static/nb/ui/evo/index.html?deploymentid=5745322406056533358933471518eISBN=9781337274509&id=586434 145&snapshotld: L x ... € → O 1 » CENGAGE MINDTAP Q Search this course x Parallel Arrays in Python D Parallel Lists Jumpinjive.py + > Terminal + 1 # Jumpin Java.py - This program looks up and prints the names and prices of coffee orders. 2 # Input: Interactive 3 # Output: Name and price of coffee orders or error message if...

  • Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...

    Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write...

  • The Jumpin Jive coffee shop charges $2 for a cup of coffee and offers add ins...

    The Jumpin Jive coffee shop charges $2 for a cup of coffee and offers add ins shown in the pseudocode. Using the following Pseudocode, Design the logic for an application that allows a user to enter ordered add ins continuously until a sentinel value is entered. After each item, display its price or the message "Sorry, we do not carry that" as an output. After all items have been entered, display the total price for the order. Please write it...

  • Create an online order form and calculator for Joe’s Coffee House.   Joe sells regular and decaff...

    Create an online order form and calculator for Joe’s Coffee House.   Joe sells regular and decaff coffee. Customers have the option of adding cream, sugar, artificial sweetener, cinnamon and caramel to their coffee. They can have any number of the options available or none at all.   Customers can add one or more muffins to their order. Possible muffins are blueberry, chocolate chip, banana nut and bran. Coffee is $3.00 Coffee Add-Ins are $0.25 a piece Muffins are $2.25 apiece. Your...

  • I need the pseudocode and python for the four attached problems: 1. (Chapter 5 - For...

    I need the pseudocode and python for the four attached problems: 1. (Chapter 5 - For Loop) Logic Technical College has a current tuition of $10,000 per year. Tuition is scheduled to increase by 5% each year. Using a FOR loop, design a program that calculates and displays the tuition each year for the next ten years, like so: The tuition for year 1 will be: 10500.00 The tuition for year 2 will be: 11025.00 ……….. (You, of course will...

  • c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please...

    c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please do all parts. previously I post 3 time for part1 ,2 and 3 but I can't make it into one complete program code. I even try to post a questions ask and post the 3 parts of code for experts to put it together. But experts said it's not enough information. please help... Thank you ! Program Objectives: Allow students to create arrays Allow...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • *Use Java to create this program* For this assignment, you will be building a Favorite Songs...

    *Use Java to create this program* For this assignment, you will be building a Favorite Songs application. The application should have a list with the items displayed, a textbox for adding new items to the list, and four buttons: Add, Remove, Load, and Save. The Add button takes the contents of the text field (textbox) and adds the item in it to the list. Your code must trim the whitespace in front of or at the end of the input...

  • In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST...

    In Java, please write the program for the following program. Please TEST YOUR PROGRAM. You MUST use GUI, that means all user input must be through the windows. The "first window" is the window on the top left of the following picture. Add 5 more items to be purchased. Search is accessed from second window, top right. Thw third window is the bottom left, and the fourth window is the bottom right. The program MUST CONTAIN EVERYTHING IN THE PICTURES....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT