Question

# Problem 1 (Defining products and Creating a Menu) Write a program called a2_p1.py that asks a...

Problem 1 (Defining products and Creating a Menu)

Write a program called a2_p1.py that asks a shop owner for product information and creates a menu system that allows customers to purchase multiple products of varying quantities. The program should start by asking the shop owner’s name (string) and company name (string). Next it should ask for three (3) products (strings), their prices (int – not ideal, but for now we will keep it this way), and the number of products in stock (int). Finally, it should display a menu.

Short Summary:

1. Implemented the program as per requirement
2. Attached source code and sample output

**************Please do upvote to appreciate our time. Thank you!******************

Source Code:

class a2_p1(object):
def validateAndDisplayMenu(self,num): #function to prompt user and validate input
companyName = input("What is your company name? ") #Ask user for company name
print("Hi ",name,"!","Let's setup a sales menu for '",companyName,"'.")
print("Please enter the following information for ",companyName,"'s products.")
prodList = [None] * num #create product list of product size
priceList= [None] * num #create price list of product size
stockList= [None] * num #create stock list of product size
for i in range(num): #loop number of product times
var = "Enter Product " +str(i+1) + " information: Name: "
prodName = input(var)
prodList[i]=prodName
valid=False
while valid==False: #loop until valid price is entered
var=prodName+"'s price:"
price=input(var)
if price.isnumeric() and int(price) > 0:
priceList[i]=price
valid=True
else:
print("Price must be a number, please enter again.")
valid=False
valid=False #reassign valid to false
while valid==False: #loop until valid stock is entered
var="How many "+prodName+" in stock:"
stock=input(var)
if stock.isnumeric() and int(stock) > 0:
stockList[i]=stock
valid=True
else:
print("Enter again.Stock must be a positive number")
valid=False
for i in range(num):
print(i,". ",prodList[i],"(each \$",priceList[i],")", stockList[i]," in stock")
print(" Press 4 when you are done! ===================================")

if __name__ == "__main__":
product=3

Code Screenshot:

Output:

**************Please do upvote to appreciate our time. Thank you!******************

#### Earn Coins

Coins can be redeemed for fabulous gifts.