Figure 1 shows a Python program that calculates the total cost of a hotel stay.
# Figure 1
def calculate_stay(nights, room_rate, meal_plan):
if meal_plan == 0:
return nights * room_rate
else:
return (nights * room_rate) + (nights * 25)
num_nights = int(input("Enter number of nights: "))
rate = int(input("Enter room rate per night: "))
breakfast = int(input("Enter 1 for breakfast, 0 for room only: "))
total_cost = calculate_stay(num_nights, rate, breakfast)
print("Total cost of stay is: £" + str(total_cost))
Describe one way that the program in Figure 1 could be made more robust.
Practise AQA GCSE Computer Science Robust and secure programming with exam-style questions for GCSE Computer Science. 28 questions, matched to the AQA GCSE Computer Science (8525) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.