Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

Evaluate the definite integrals in Problem. V - 8x dx V2x 8 x

Answered: 1 week ago