Pre Release Material
Summer 2017 | O Levels | Computer Science
In Preparation for the
examination candidates should attempt the following practical tasks by writing and testing a program or programs.
The
Organizer of a senior citizens’ club has arranges outings for the members. For
each of these outings a coach is hired, meals at a restaurant are reserved and
tickets for the theater has booked. A program is required to work out the costs
and provide a printed list showing everyone on the outing.
Write and test a program for
the club organizer.
− Your program must include
appropriate prompts for the entry of data.
− Error message and other
output need to be set out clearly.
− All variables, constants and
other identifiers must have meaningful names.
You will need to
complete these three tasks. Each
task must be fully tested.
TASK
1
The organizer
finds out how many senior citizens are interested in the outing. The program
for Task 1 works out the cost for the information.
Number of people
|
Hire of couch
|
Cost of a meal
|
Cost of theater ticket
|
12 – 16
|
150
|
14.00
|
21.00
|
17 – 26
|
190
|
13.50
|
20.00
|
27 – 39
|
225
|
13.00
|
19.00
|
The minimum number of senior
citizens needed for the outing to go ahead is 10; there cannot be more than 36
senior citizens on the outing. A minimum of two carers go on the outing. With
an additional carer needed if more than 24 citizens go on the outing. Carers do
not have to pay anything for the outing. Workout the total cost per person for
the senior citizens.
Task
2
Using your results from Task
1, record the names of the people on the outing and the amount they have paid;
include the carers on the outing. If there are spare places on the coach then
extra people can be added; they are charged the same price as the other
citizens. Calculate the total amount of money collected. Print out the list of
the people on the outing.
Task
3
Show whether the outing has
made a profit or has broken even using the estimated cost from the Task 1 and
money collected from Task 2.
Solution
(Pseudo Code)
Task 1
INPUT “Enter
numbers of senior citizens : ”, citizen
WHILE (citizen
< 10 OR citizen > 36)
PRINT (“The minimum number is
10 and maximum number is 36.”)
INPUT (“Enter numbers of
senior citizens :”), citizen
ENDWHILE
IF citizen >
24 THEN people = citizen + 3
ELSE People = citizen + 2
ENDIF
IF people >=
12 AND people <= 16 THEN CoachCost=150 total = 150 + (14.00 * people) +
(21.00 * people) ENDIF
IF people >=
17 AND people <= 26 THEN CoachCost=190 total =
190 + (13.50 * people) + (20.00 * people) ENDIF
IF people >= 27 AND
people <= 39 THEN CoachCost=225 total = 225 + (13.00 * people) + (19.00 *
people) ENDIF
CostPerPerson =
total/citizen
TASK 2
PRINT (“Extra
people can be added; they will be charged the same as the senior citizens.”)
IF people >=
12 AND people <= 16 THEN seats = 16 – people ENDIF
IF people >=
17 AND people <= 26 THEN seats = 26 – people ENDIF
IF people >= 26 AND
people <= 39 THEN seats = 39 – people ENDIF
ExtraAmount = CostPerPerson
* seats
TotalAmount = total + ExtraAmount
UpdatedPeople = people
IF seats >= 1
THEN UpdatedPeople = people + seats
PRINT (“seats available for ”, seats,”
person(s), Enter Name and Amount for people will to go for outing”)
FOR d = c to UpdatedPeople
INTPUT (“Enter the name of
person on the outing”) , name(d)
INTPUT (“Enter the amount
paid by the person ”) , amount(d)
AmountPaid = AmountPaid +
amount(d)
NEXT
ENDIF
FOR c = 1 to UpdatedPeople
PRINT (“The Citizens’ Name :”,
name(c) ,” & the amount submitted :”, amount(c))
NEXT
Task 3
EstimatedCost = CoachCost+(UpdatedPeople*(MealCost+TicketCost))
Profit = AmountPaid –
EstimatedCost
IF profit > 0
THEN PRINT (“ The Profit Gained : “, profit)
ELSE PRINT (“The
Break Even Point Value : “,total)
Explanation
Task 3 is all
about finding the profit by subtracting the expected cost calculated in task 1
with the total of amount paid in task 2. But we also have to carefully add the
meal and ticket cost of extra people going on the outing in the expected cost,
using formula : EstimatedCost = CoachCost + (people x (meal cost + ticket
cost)) and then, Amount paid - Estimated Cost