2Easy
0/1

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.

[1]

Robust and secure programming Questions

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.

PreviousNext

Robust and secure programming Questions

  1. GCSE
  2. /Computer Science
  3. /Robust and secure programming