A cinema booking program stores the data below. State the most appropriate data type for each item. [4]
(a) The number of seats booked
(b) The price of a ticket, e.g. 7.50
(c) Whether the customer has paid
(d) The customer's postcode
- (a) Integer; accept int(1)
- (b) Real (accept float)(1)
- (c) Boolean; accept bool(1)
- (d) String; accept str; reject character / char(1)
- Answer: (a) Integer (b) Real (c) Boolean (d) String
- Examiner tip: A postcode mixes letters, digits and spaces, so it is a string – it is not an integer just because it contains numbers. Use the spec's data-type names (integer, real, Boolean, character, string).