0% found this document useful (0 votes)
17 views1 page

Stacks Program for Share Management

The document contains a Python program that implements a stack for managing share records. It allows users to push new records, pop existing records, and display all records through a menu-driven interface. The program handles cases of stack underflow and provides a simple user interaction for managing shares.

Uploaded by

dishaad36
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Stacks Program for Share Management

The document contains a Python program that implements a stack for managing share records. It allows users to push new records, pop existing records, and display all records through a menu-driven interface. The program handles cases of stack underflow and provides a simple user interaction for managing shares.

Uploaded by

dishaad36
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#STACKS PROGRAM

#[Link] XIIF2

shares = []
def isEmpty(shares):
if shares==[]:
return True
else:
return False

def push(shares):
company_name = input("Enter Company Name: ")
cust_name = input("Enter Customer Name: ")
no_of_shares = int(input("Enter Number of Shares: "))
amt_per_share = float(input("Enter Amount per Share: "))
[Link]((company_name, cust_name, no_of_shares, amt_per_share))
print("Record pushed")

def pop(shares):
if isEmpty(shares):
print("Stack empty, UNDERFLOW CASE")
else:
print("Popped record:", [Link]())

def display(shares):
if isEmpty(shares):
print("Stack empty, UNDERFLOW CASE")
else:
print("Stack contents:")
for record in shares:
print(record)

def menu():
while True:
print("\nMENU DRIVEN PROGRAM:")
print("1. Push")
print("2. Pop")
print("3. Display")
print("4. Quit")
choice = input("Enter your choice (1-4): ")
if choice == "1":
push(shares)
elif choice == "2":
pop(shares)
elif choice == "3":
display(shares)
elif choice == "4":
print("Exiting program.")
break
else:
print("Invalid choice. Please try again.")

menu()

You might also like