You are on page 1of 3

TASK-1

SET ARRAY ticket_type [5]  ["one adult", "one child", "one senior", "family (2 adults/seniors & 3 children", "group (6 or more) price per person"] AS STRING
SET ARRAY cost_1day [5]  [20.00, 12.00, 16.00, 60.00, 15.00] AS REAL
SET ARRAY cost_2day [5]  [30.00, 18.00, 24.00, 90.00, 22.50] AS REAL

SET ARRAY attraction [3]  ["lion feeding", "penguin feeding", "evening barbecue 2 day tickets only"] AS STRING
SET ARRAY attraction_cost [3]  [2.50, 2.00, 5.00] AS REAL
SET ARRAY days [7]  ["day 1", "day 2", "day 3", "day 4", "day 5", "day 6", "day 7"] AS STRING

PRINT "Ticket type Cost for 1 day Cost for 2 days"


FOR count  1 to 5
PRINT ticket_type(count), cost_1day(count), cost_2day(count)
NEXT count

PRINT "Extra attraction Cost per person"


FOR count  1 to 3
PRINT attraction(count), attraction_cost(count)
NEXT count

PRINT "Days available for booking (Today is Day 1)"


FOR count  1 to 7
PRINT days(count)
NEXT count
TASK-2
SET VARIABLE booking_num, num_days, day_choice, ticket_choice, adults, children, seniors AS INTEGER
SET VARIABLE grp_adults, grp_children, grp_seniors, families, lion, penguin, barbecue AS INTEGER
SET VARIABLE cost, tot_cost AS REAL
SET VARIABLE ans AS CHAR
booking_num  1
REPEAT
INPUT "Enter your choice of ticket (1 to 5)", ticket_choice
IF (ticket_choice = 1) THEN
INPUT "How many adult tickets (0 for none)", adults
ELSEIF (ticket_choice = 2) THEN
INPUT "How many child ticket (0 for none)", children
IF (adults < 1) OR (children > (adults * 2))
PRINT "INVALID… Children should be accompanied by adults. 1 adult can bring 2 children ONLY"
ENDIF
ELSEIF (ticket_choice = 3) THEN
INPUT "How many senior ticket (0 for none)", seniors
ELSEIF (ticket_choice = 4) THEN
INPUT "How many family ticket", families
ELSEIF (ticket_choice = 5) THEN
REPEAT
INPUT "How many adult ticket (0 for none)", grp_adults
INPUT "How many child ticket (0 for none)", grp_children
INPUT "How many senior ticket (0 for none)", grp_seniors
IF ((grp_adults + grp_seniors + grp_children) < 6) THEN
PRINT "INVALID...Group ticket should have minimum 6 people"
ENDIF
UNTIL ((grp_adults + grp_seniors + grp_children) >= 6)
ENDIF
INPUT "Want to buy more tickets (y/n)", ans
UNTIL (ans = "n")
INPUT "Any Lion feeding needed (0 for none)", lion
INPUT "Any Penguin feeding needed (0 for none)", penguin
INPUT "How many days(1 or 2) you want to visit", num_days
WHILE (num_days < 1) OR (num_days > 2)
INPUT "INVALID DAYS...How many days(1 or 2) you want to visit", num_days
ENDWHILE
IF (num_days = 1) THEN
INPUT "Enter any 1 day between 1 & 7 you want to visit", day_choice
WHILE (day_choice < 1) OR (day_choice > 7)
INPUT "INVALID DAY...Enter any 1 day between 1 & 7 you want to visit", day_choice
ENDWHILE
cost  (adults * cost_1day(1)) + (children * cost_1day(2)) + (seniors * cost_1day(3)) + (families * cost_1day(4)) + ((grp_adults + grp_seniors +
grp_children) * cost_1day(5)
ELSE
INPUT "Enter any 2 consecutive days between 1 & 7 you want to visit", day_choice
WHILE (day_choice <> 12) OR (day_choice <> 23) OR (day_choice <> 34) OR (day_choice <> 45) OR (day_choice <> 56) OR (day_choice <> 67)
INPUT "INVALID DAY...Enter any 2 consecutive day between 1 & 7 you want to visit", day_choice
ENDWHILE
cost  (adults * cost_2day(1)) + (children * cost_2day(2)) + (seniors * cost_2day(3)) + (families * cost_2day(4)) + ((grp_adults + grp_seniors +
grp_children) * cost_2day(5)
INPUT "How many Evening barbecue needed (0 for none)", barbecue
ENDIF
tot_cost  (cost + (lion * attraction_cost (1)) + (penguin * attraction_cost (2)) + (barbecue * attraction_cost (3)))
PRINT "Booking No No.of Adult No.of Child No.of Senior No.of Family Total in a Group Total Cost"
PRINT booking_num, adults, children, seniors, families, (grp_adults + grp_seniors + grp_children), tot_cost
booking_num  booking_num + 1
TASK-3

SET VARIABLE count AS INTEGER

IF (children = 0) AND ((adults + seniors) >= 6) THEN


PRINT "buying group ticket is better than ", (adults + seniors), “individual tickets"
ENDIF

WHILE ((adults + seniors) >= 2) AND (children >= 3) THEN


IF (adults >= 2) THEN
adults  adults - 2
ELSEIF (seniors >= 2) THEN
senoirs  seniors - 2
ENDIF
children  children - 3
count  count + 1
ENDWHILE

IF (count > 0) THEN


PRINT "buying”, count, "family tickets is better than individual tickets"
PRINT "Following tickets should be bought seperately (0 = none)"
PRINT "No.of Adult No.of Child No.of Senior"
PRINT adults, children, seniors
ENDIF

WHILE ((grp_adults + grp_seniors) >= 2) AND (grp_children >= 3) THEN


IF (grp_adults >= 2) THEN
grp_adults  grp_adults - 2
ELSEIF (grp_seniors >= 2) THE
grp_senoirs  grp_seniors - 2
ENDIF
grp_children  grp_children - 3
count  count + 1
ENDWHILE

IF (count > 0) THEN


PRINT "buying", count, "family tickets is better than group tickets"
PRINT "Following tickets should be bought seperately (0 = none)"
PRINT "No.of Adult No.of Child No.of Senior"
PRINT grp_adults, grp_children, grp_seniors
ENDIF

You might also like