Friday 12 February 2021

Practical No. 15: - Write a menu driven program which insert, delete and display the details of a book such as book_id, book_name and price using Stack.

 '''

Practical no. 15: Write a manu driven program which insert, delete and display

the deletails of a book such as book_id, book_name and price using stack.

'''

Book=[]

c='y'

while(c=='y' or c=='Y'):

    print("1: Add Book Details: ")

    print("2: Delete Book Details: ")

    print("3: Display Book Details: ")

    choice=int(input("Enter Your Choice: "))

    if(choice==1):

        book_id=int(input("Enter Book Id: "))

        book_name=input("Enter Book Name: ")

        price=float(input("Enter Book Price: "))

        B=(book_id,book_name,price)

        Book.append(B)

    elif(choice==2):

        if(Book==[]):

            print("Stack Empty")

        else:

            print("Deleted element is: ",Book.pop())

    elif(choice==3):

        L=len(Book)

        while(L>0):

            print(Book [L-1])

            L=L-1

    else:

        print("Wrong Input")

    c=input("Do you want to continue? press 'y' to continue: ")    

        

            

 


                             

                

              



                 


    



No comments:

Post a Comment