Question
Create a PYTHON program that allows a user to interactively purchase a number of tickets, then provides an opportunity to enter some (fake) credit card
Create a PYTHON program that allows a user to interactively purchase a number of tickets, then provides an opportunity to enter some (fake) credit card information to pay for the tickets, and finally, prints out a receipt for the user (to the screen, not on paper). Finally, the program should backup all the transactions into a text file
You are free to design and implement the software however you see fit. Here are some requirements that must be incorporated into your program 1. You must display a welcome message when the program starts. At a minimum, this message should contain the name of your program, the name of the program developer and your student ID. 2. The welcome message should also have a row of asterisks at the top and the bottom, just long enough to extend over the text. Hint: Use a For loop for this. 3. When the user goes to purchase tickets, they should be able to purchase a child, adult, senior or concession ticket(s). Each ticket category should cost a different amount; its up to you to choose how much each ticket costs. They should be able to purchase as many tickets (across all categories) as they like 4. When the user goes to finalise their order, the total cost should display on screen. Your program should then ask the user to enter their (fake) credit card details, check the credit card details and, if valid, display a final receipt 5. Finally, the program should backup the transaction into a text file
This is the current code i have:
# a function to print a starline def printStarLine(count): for i in range(0,count): print("*", end="") print(" ") # print the introductry information printStarLine(40) print("WELCOME TO ONLINE RESERVATION SYSTEM") print("DEVELOPED BY :") print("STUDENT ID:") printStarLine(40)
# fix the cost of the three tickets ADULTTICKETCOST = 100 CHILDTICKETCOST = 20 CONSESSIONTICKETCOST = 56
# Choice variable keeps check of whether the user wants to purchase more tickets continueBooking = "Y"
# variables to store totalAmount and count of each type of ticket totalAmount = 0 adultTicketCount = 0 childTicketCount = 0 consessionTicketCOunt = 0
# While the user wants to book tickets while(continueBooking == 'Y'): choice = input("PRESS A FOR ADULT, C FOR CHILD AND S FOR SENIOR OR CONCESSION TICKET: ") numOfTickets = int(input("ENTER THE NO OF TICKET YOU WISH TO PURCHASE IN THIS CATEGORY: ")) continueBooking = input("DO YOU NEED TO PURCHASE MORE TICKET - Y/N: ") # increment the selected ticket count and t if(choice == 'A'): adultTicketCount = adultTicketCount+1 totalAmount = totalAmount + ADULTTICKETCOST*numOfTickets elif(choice == 'C'): childTicketCount = childTicketCount+1 totalAmount = totalAmount + CHILDTICKETCOST*numOfTickets else: consessionTicketCOunt = consessionTicketCOunt+1 totalAmount = totalAmount + CONSESSIONTICKETCOST*numOfTickets
f = open("output.txt", "w")
# Take credit card details print("Total Amount: " + str(totalAmount)) print("TO PAY, ENTER YOUR CREDIT CARD DETAILS: ") creditCardNumber = input("ENTER CREDIT CARD DETAILS: ") name = input("NAME:") expiryDate = input("EXPIRY DATE: ") CVVNum= input("CVV Number: ")
# Now print the ouput and simultaneusly write to the file print("Ticket has been confirmed: ") f.write("Ticket has been confirmed: ") if adultTicketCount != 0: print(str(adultTicketCount) + "ADULT") f.write(str(adultTicketCount) + "ADULT ") if childTicketCount != 0: print(str(childTicketCount) + "CHILD") f.write(str(childTicketCount) + "CHILD ") if consessionTicketCOunt != 0: print(str(consessionTicketCOunt) + "CONSESSION") f.write(str(consessionTicketCOunt) + "CONSESSION ")
print("Total Amount paid = "+ str(totalAmount)) f.write("Ticket has been confirmed: ")
f.close()
THERE IS ONE MORE REQUIREMENT FOR THIS HOMEWORK. Your submission should consist of three Python scripts that implement the computer program (ticket.py, checkout.py and main.py). The main.py script runs the main logic of the program and will use instances of Ticket and Checkout classes to simulate purchasing a spectator ticket.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started