Ask Question
8 July, 03:45

Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4 tickets. No more than 100 tickets can be sold. Implement a program that prompts the user for desired number of tickets and then display the number of remaining tickets. Do not allow the user to enter an invalid number of tickets. Repeat until all tickets have been sold, and then display the total number of buyers. Safe the file as Tickets. java.

+2
Answers (1)
  1. 8 July, 03:47
    0
    Python code explained below

    Explanation:

    **CODE:

    tickets = 100

    count = 0

    # Loop runs until tickets become zero

    while tickets!=0:

    print ("There are currently", tickets, "tickets remaining.")

    # Taking input from user for tickets

    userInput = int (input ("How many tickets would you like to purchase?"))

    # If user enters more than 4 tickets

    if userInput > 4:

    print ("You cannot purchase more than 4 tickets")

    # If available tickets are less than user requirment

    elif tickets < userInput:

    print ("Available tickets are less than required")

    else:

    # Count increment to store the users who brought

    count + = 1

    # Decrementing the available tickets with the user requirements

    tickets - = userInput

    print ("Transaction successful")

    print ()

    print ("All the tickets are sold")

    print ("The total number of buyers was ", count)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write an application to pre-sell a limited number of cinema tickets. Each buyer can buy as many as 4 tickets. No more than 100 tickets can ...” in 📗 Social Studies if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers