In this project, you will design a program to perform the following task: Design
ID: 3572887 • Letter: I
Question
In this project, you will design a program to perform the following task: Design a program for a cafe that will allow a user to gather some customer market research data. When a customer places an order, the clerk will ask for the customer's age and zip code. The clerk enters that data as well as the number of items the customer orders. The program operates until the clerk enters a zero for the zip code at the end of the day. At the end of the day. the program will display the following: A count of the number of items ordered by all customers. A count of the number of items ordered by customers under 30. A count of the number of items ordered by customers over 65. A total count of how many customers ordered items. You will turn in your: inputs outputs pseudocode flowchart desk check Python code.Explanation / Answer
inputs: age, zipcode, items
outputs:
Number of items ordered by all customers
Number of customers below the age of 30
Number of customers over the age of 65
Total number of customers
python code:
class Customer:
age = 0
zipcode = 0
items = 0
def __init__(self, age, zipcode, items):
self.age = age
self.zipcode = zipcode
self.items = items
customers = []
age = input('Enter customer age: ')
items = input('Enter the number of items ordered by customer: ')
zipcode = input('Enter the zipcode of the customer: ')
while zipcode != 0:
customer = Customer(age, zipcode, items)
customers.append(customer)
age = input('Enter customer age: ')
items = input('Enter the number of items ordered by customer: ')
zipcode = input('Enter the zipcode of the customer: ')
under30 = 0
over65 = 0
num_items = 0
for customer in customers:
if customer.age<30:
under30 += 1
if customer.age>65:
over65 += 1
num_items += customer.items
print "Number of items ordered by all customers: ", num_items
print "Number of customers below the age of 30: ", under30
print "Number of customers over the age of 65: ", over65
print "Total number of customers: ", len(customers)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.