A program is required to calculate the total registration fee for an event. Bookings are made either as individual tickets or as corporate exhibition floor space.
The user enters the number 10 if the booking is for individual tickets or the number 20 if the booking is for corporate floor space. The user then enters either the number of tickets (an integer) or the exhibition floor area in square meters (a real number).
The program checks for invalid input. If the input is valid, the program calculates and displays the total fee.
Currency formatting with two decimal places and a currency symbol is not required.
| Booking category | Ticket count | Floor area | Output |
|---|---|---|---|
| 10 | 3 | Total fee is 37.5 | |
| 10 | 0 | Invalid number of tickets | |
| 20 | 4.5 | Total fee is 384.75 | |
| 20 | -3.2 | Invalid floor area | |
| 15 | Invalid booking type |
Open file Q03.py which contains the following skeletal code:
# TODO: create an integer variable named bookingType and set it to 0
TICKET_PRICE = 12.50
SPACE_RATE = 85.50
bookingType = int(input("Enter booking type (10 or 20): "))
if bookingType != 10 [operator] bookingType != [constant]:
print("Invalid booking type")
else:
if bookingType == 10:
count = int(input("Enter number of tickets: "))
if [check for 0 or negative count]:
print("Invalid number of tickets")
else:
total = count * TICKET_PRICE
print("Total fee is " + str(total))
elif bookingType == [constant]:
area = [accept a real value for area]
if area [relational operator] 0:
print("Invalid floor area")
else:
total = [calculate total fee based on floor space]
# TODO: add a line to display an informative message and the total fee
Amend the code to:
bookingType and set it to 0.Do not add any additional functionality.
Save your amended code as Q03FINISHED.py
51 exam-style questions on Edexcel GCSE Computer Science Develop code, covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.