Example of Pseudocode
Example of Pseudocode
0 PSEUDOCODE
//function prototype
VOID displayt1 (int&)
VOID displayt2 (int, int, int&, int&, int&)
VOID displayt3 ()
VOID displayt4 (char&)
FLOAT Calcamount (float, float)
VOID favmovie (int, int, int, int)
//main function
START
SET disc = 0.09
DECLARE count = 0, count01 = 0, count02 = 0, count03 = 0, count04 = 0,
seatcode[80], ans = ‘Y’, maxamount = -1 and minamount = 999
//MOVIE SELECTION
DO //to repeat the process until customer enter the right movie code
displayt1 (movcode) //function call
PROMPT user to enter movie code (movcode)
READ movcode
IF (movcode == 01)
movname = Mimi & Friends The Movie
time = 10:00
count01++
ELSE IF (movcode == 02)
movname = The Secret Life of Haziqah
time = 13:00
count02++
ELSE IF (movcode == 03)
movname = Atiqah dan Kerusi Ajaib
time = 17:00
count03++
ELSE IF (movcode == 04)
movname = Dendam Faizah
time = 22:00
count04++
ELSE
DISPLAY “INVALID MOVIE CODE”
END IF
END WHILE (movcode < 01 || movcode > 04)
//TICKET PRICE
displayt2 (citizen, movcode, qttChild, qttStudent, qttAdult) //function call
SWITCH (citizen) //calculate the price based on citizenship
case 1:CALCULATE
priceChild = qttChild * 14.00
priceAdult = qttAdult * 23.00
priceStudent = qttStudent * 17.00
break
case 2:CALCULATE
priceChild = qttChild * 19.00
priceAdult = qttAdult * 28.00
priceStudent = 0.00
break
END SWITCH
CALCULATE
no_ofseat = qttStudent + qttAdult + qttChild
//POSITION SEATING
displayt3 () //function call
FOR (int i = 0; i < no_ofseat; i++) //looping to store array for seatcode
PROMPT user to enter seat number
READ seatcode[i]
CALCULATE
amount1 = priceAdult + priceChild + priceStudent + foodprice
//MEMBERSHIP DISCOUNT
IF (member == 1)
amount2 = disc * amount1
ELSE IF (member == 2)
amount2 = 0.00
END IF
CALCULATE
finamount = Calcamount (amount1, amount2) //function call
//CUSTOMER’S RECEIPT
DISPLAY custname, cont, email, movname and time
FOR (int i = 0; i < no_ofseat; i++) //looping to display array for seatcode
DISPLAY seatcode[i]
IF (foodcode == 1)
DISPLAY food
END IF
DISPLAY amount1, amount2 and finamount
CALCULATE
count++ //to calculate the number of customer in a day
totalamount += finamount
END WHILE
CALCULATE
average = totalamount / count
//COMPANY REPORT
DISPLAY totalamount and average
favmovie (count01, count02, count03, count04) //function call
DISPLAY maxamount and minamount
RETURN
END
//function definition
//to display the movie selection and return the movie code
VOID displayt1 (int& movcode)
START
DISPLAY movie selection table
DISPLAY “REMARKS : ‘Dendam Faizah ‘ does not available for child ticket!”
PROMPT user to enter movie code (movcode)
READ movcode
END
//to display the ticket price by age group based on citizenship and return the quantity of ticket
VOID displayt2 (int citizen, int movcode, int& qttChild, int& qttStudent, int& qttAdult)
START
IF (citizen == 1)
IF (movcode == 04)
DISPLAY price per ticket for adult: 23.00 and price per ticket for
student: 17.00
qttChild = 0
ELSE IF (movcode != 04)
DISPLAY price per ticket for adult: 23.00, price per ticket for student:
17.00 and price per ticket for children: 14.00
END IF
PROMPT user to enter quantity for adult’s ticket (qttAdult) and student’s ticket
(qttStudent)
READ qttAdult and qttStudent
IF (movcode != 04)
PROMPT user to enter quantity for children’s ticket (qttChild)
READ qttChild
END IF
ELSE IF (citizen == 2)
IF (movcode == 04)
DISPLAY price per ticket for adult: 28.00
qttChild = 0
ELSE IF (movcode != 04)
DISPLAY price per ticket for adult: 28.00 and price per ticket for
children: 19.00
END IF
PROMPT user to enter quantity for adult’s ticket (qttAdult)
READ qttAdult
IF (movcode != 04)
PROMPT user to enter quantity for children’s ticket (qttChild)
READ qttChild
END IF
qttStudent = 0
END IF
END
//to display the food and beverages table and return the setcode
VOID displayt4 (char& setcode)
START
DISPLAY food and beverages available menu and its price
PROMPT user to enter set code (setcode)
READ setcode
END
//to count the most chosen movie and display the most favourite movie name
VOID favmovie (int count01, int count02, int count03, int count04)
START
DECLARE max_Favmovie[4] = {count01, count02, count03, count04}, max_favmovie
= -1 and movname
IF (count01 > max_favmovie)
max_favmovie = count01
movname = “Mimi & Friends the Movie”
END IF
IF (count02 > max_favmovie)
max_favmovie = count02
movname = “The Secret Life of Haziqah”
END IF
IF (count03 > max_favmovie)
max_favmovie = count03
movname = “Atiqah dan Kerusi Ajaib”
END IF
IF (count04 > max_favmovie)
max_favmovie = count04
movname = “Dendam Faizah”
END IF
FOR (int index = 0; index < 4; index++) //looping to find how many time its being
choose
IF (max_Favmovie[index] > max_favmovie)
max_favmovie = max_Favmovie[index]
END IF
DISPLAY movname and max_favmovie
END