Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Pre Release Material

SOLVED (Pseudo Code & V.B Console Mode)

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.

Work out the total cost of the outing.


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
Record who is going on the outing and how much has been paid.

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
Identify the break-even point or profit that will be made on the outing.

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.

Whatsapp : +92 333 2076121

FaceBook : https://www.facebook.com/groups/olevelcomputers/

Youtube Channel : https://www.youtube.com/channel/UCI3PR7HREjiZiSCiM_v_KEg


Solution (Discussion)
Task 1
1. To input number of senior citizens with a prompt message.
2. Validate the input data, (ask for reentry of data if value is not in between 10 and 36)
3. Calculate number of people going on outing, two carers will accompany the senior
citizens but if senior citizens are more then 24 then one additional carer will also go
4. Calculate the expected cost for the outing according to the cost table given above
using formula :
(expected cost = couch fair + meal amount x people + ticket amount x people)
5. Calculate the cost per citizen ( because carer will not have to pay)
Using formula :
Cost per citizen = expected cost / number of senior citizens

Task 2
1. Input and store (record) the names and amount of people going on outing in one
dimensional array and total the amount paid
2. Find out if there are extra seats available on the coach
3. If seats are available then include more people (extra people) on coach
4. As extra people have to pay the same amount, add total amount paid.
5. Output the list of all the people going on outing with their names and amount they
have paid

Task 3
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 :
expected amount = people x (meal cost + ticket cost) and then, expected cost =
expected cost + extra amount.
Solution (Pseudo Code)
Task 1

DECLARE citizen, people : integer

DECLARE total, cost_per_person : real

people  0, expected_cost  0, cost_per_person  0

OUTPUT (“Enter number of senior citizens”)

INPUT citizen

WHILE (citizen < 10 OR citizen > 36)

OUTPUT (“Error in Input, value in between 10 and 36 is allowed, Kindly Reenter”)

INPUT citizen

ENDWHILE

People  citizen + 2

IF people > 24 THEN people  people + 1

IF people >= 12 AND people <= 16 THEN

Expected_cost  150 + (14.00 * people) + (21.00 * people)

ENDIF

IF people >= 17 AND people <= 26 THEN

expected_cost  190 + (13.50 * people) + (20.00 * people)

ENDIF

IF people >= 27 AND people <= 39 THEN

expected_cost  225 + (13.00 * people) + (19.00 * people)

ENDIF

cost_per_person  expected_cost/citizen
TASK 2

DECLARE name(39) : string

DECLARE amount(39) : real

DECLARE seats, updated_people, c : integer

DECLARE amount_paid : real

Seats  0, updated_people  0, amount_paid  0

FOR c  1 to people

OUTPUT (“Enter the name of person on the outing”)

INPUT name(c)

OUTPUT (“Enter the amount paid by the person”)

INPUT amount(c)

amount_paid = amount_paid + amount(c)


NEXT

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
Updated_people  people

IF seats >= 1 THEN

updated_people  people + seat

FOR d  c to updated_people

OUTPUT (“Enter the name of person on the outing”)

INPUT name(d)

OUTPUT (“Enter the amount paid by the person”)

INPUT amount(d)

amount_paid = amount_paid + amount(d)


NEXT

ENDIF

FOR c  1 to updated_people

OUTPUT (“The Citizens’ Name :”, name(c) ,” & the amount submitted :”, amount(c))

NEXT

Task 3

DECLARE profit, extra_amount : real

Profit  0, extra_amount  0

IF people>=12 AND people<=16 THEN extra_amount  people * (14.0 + 21.0)

IF people>=17 AND people<=26 THEN extra_amount  people * (13.5 + 20.0)

IF people>=17 AND people<=26 THEN extra_amount  people * (13.0 + 19.0)

expected_cost  expected_cost + extra_amount

profit  amount_paid – expected_cost

IF profit > 0 THEN OUTPUT (“ The Profit Gained : “, profit)

ELSE OUTPUT (“The Break Even Point Value : “,expected_cost)


Visual Basic (Console Mode)
Module Module1

Sub Main()

‘TASK 1

Dim citizen, people As Integer


Dim expected_cost, cost_per_person As Single

people = 0
expected_cost = 0
cost_per_person = 0

Console.Write("Enter no of senior citizens going on outing : ")


citizen = Console.ReadLine()

While citizen < 10 Or citizen > 36


Console.Write("Error, Re Enter the value in between 10 and 36 : ")
citizen = Console.ReadLine()
End While

If citizen > 24 Then people = citizen + 3 Else people = citizen + 2


If people >= 12 And people <= 16 Then
expected_cost = 150 + (14.0 * people) + (21.0 * people)
End If
If people >= 17 And people <= 26 Then
expected_cost = 190 + (13.5 * people) + (20.0 * people)
End If
If people >= 27 And people <= 39 Then
expected_cost = 225 + (13.0 * people) + (19.0 * people)
End If

cost_per_person = expected_cost / citizen

‘TASK 2

Dim name(39) As String


Dim amount(39) As Single
Dim seats, updated_people, c As Integer
Dim amount_paid As Single
seats = 0
updated_people = 0
amount_paid = 0

For c = 1 To people
Console.Write("Enter the name of person on the outing : ")
name(c) = Console.ReadLine()
Console.Write("Enter the amount paid by the person : ")
amount(c) = Console.ReadLine()
amount_paid = amount_paid + amount(c)
Next

If people >= 12 And people <= 16 Then


seats = 16 - people
End If
If people >= 17 And people <= 26 Then
seats = 26 - people
End If
If people >= 26 And people <= 39 Then
seats = 39 - people
End If

updated_people = people

If seats >= 1 Then


updated_people = people + seats

For d = c To updated_people
Console.Write("Enter the name of person on the outing : ")
name(d) = Console.ReadLine()
Console.Write("Enter the amount paid by the person : ")
amount(d) = Console.ReadLine()
amount_paid = amount_paid + amount(d)
Next

End If

For c = 1 To updated_people
Console.WriteLine("The Citizens’ Name :" & name(c) & " and the amount
paid : " & amount(c))
Next

‘TASK 3

Dim profit, extra_amount As Single

If people >= 12 And people <= 16 Then extra_amount = people * (14.0 + 21.0)
If people >= 17 And people <= 26 Then extra_amount = people * (13.5 + 20.0)
If people >= 17 And people <= 26 Then extra_amount = people * (13.0 + 19.0)

expected_cost = expected_cost + extra_amount

profit = amount_paid - expected_cost

If profit > 0 Then Console.WriteLine(" The Profit Gained : " & profit) Else
Console.WriteLine("The Break Even Point Value : " & expected_cost)
Console.ReadKey()
End Sub

End Module

You might also like