Question: We are doing the fruit stand project in programming. i have parts 1-3 correct and just need help with part 4. the instructions as well

We are doing the fruit stand project in programming. i have parts 1-3 correct and just need help with part 4. the instructions as well as the example are:

Part 4 - Process All Customer Orders Continue the fruit_stand.py program. It should prompt the vendor for customer names, and then for each customer calculate the total. The program should only stop once the vendor types "done" for a customer name. The following is an example. Your program must first prompt the vendor for the fruit names and prices (see parts 1, 2) before prompting for customer names and fruit quantities.

PS C:\Users\ssiva\Desktop> python fruit_stand.py

Enter a fruit name (or done): Mango

Enter a fruit name (or done): Strawberry

Enter a fruit name (or done): Kiwi

Enter a fruit name (or done): done

Enter the price for Mango: 2.54

Enter the price for Strawberry: 0.23

Enter the price for Kiwi: .75

Enter customer name (or done): Bob

Mango($2.54) Quantity: 3

Strawberry($0.23) Quantity: 10

Kiwi($0.75) Quantity: 2

Bob's total purchase is $11.42

Enter customer name (or done): Lisa

Mango($2.54) Quantity: 10

Strawberry($0.23) Quantity: 40

Kiwi($0.75) Quantity: 20

Lisa's total purchase is $49.6

Enter customer name (or done): Sam

Mango($2.54) Quantity: 0

Strawberry($0.23) Quantity: 0

Kiwi($0.75) Quantity: 1

Sam's total purchase is $0.75

Enter customer name (or done): done

PS C:\Users\ssiva\Desktop>

***this is parts 1-3 that i already have:

# Part 1

fruits = []

fruit = ""

while fruit != "done":

fruit = raw_input("Enter a fruit name (or done): ")

if fruit != "done":

ruits = fruits + [fruit]

print("Your fruit list is: " + str(fruits))

# Part 2 prices = []

for a_fruit in fruits:

price = raw_input("Enter the price for " + a_fruit + ": ")

prices += [float(price)]

print("Your price list is: " + str(prices))

#Part 3

total = 0

for x in range(0,len(fruits)):

quantity = raw_input(fruits[x] + "($ " + str(prices[x])+ ") Quantity: ")

total += float(quantity)*prices[x]

print("Your total purchase is $", str(total))

#Part 4

#for each customer

# for each fruit/ price pair

while True:

name = raw_input(" Enter customer name (or done): ")

if name == "done":

break

total = 0

for i in range(0,len(fruits)):

quantity = raw_input(fruits[i] + "$" + str(prices[i] + ") Quantity: ")

total += float(quantity) * prices[i]

print(name + "total purchase is $" + str(total))

i tried to run part 4 but i keep getting an error :(

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!