0% found this document useful (0 votes)
5 views

Example of Pseudocode

Uploaded by

2022678956
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Example of Pseudocode

Uploaded by

2022678956
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

4.

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

WHILE (ans == ‘Y’ || ans == ‘y’) //to enter next customer

PROMPT user to enter name (custname), contact number (cont), email


(email), citizenship (citizen) and membership (member)
READ custname, cont, email, citizen and member

//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]

//FOOD AND BEVERAGES


PROMPT user to enter food and beverages’s set code (setcode)
READ foodcode
IF (foodcode == 1)
displayt4 (setcode) //function call
SWITCH (setcode) //to determine the food price
case ‘A’:
food = “2 Mineral Water and 1 Medium Popcorn”
foodprice = 13.00
break
case ‘B’:
food = “2 Cokes and 1 Large Popcorn”
foodprice = 20.00
break
case ‘C’:
food = “2 Cokes, 1 Mineral Water, 1 Large Popcorn and
7 Pieces Nugget”
foodprice = 30.00
break
default :
food = “INVALID FOOD CODE”
foodprice = 0.00
break
END SWITCH
ELSE IF (foodcode == 2)
foodprice = 0.0
END IF

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

//FIND THE HIGHEST AND LOWEST AMOUNT


IF (finamount > maxamount)
maxamount = finamount
END IF
IF (finamount < minamount)
minamount = finamount
END IF

//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

PROMPT user to enter next customer or not (ans)


READ ans

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 position of seating table


VOID displayt3 ()
START
DISPLAY position of seating table
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 return finamount


FLOAT Calcamount (float amount1, float amount2)
START
DECLARE finamount
CALCULATE
finamount = amount1 – amount2
RETURN finamount
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

You might also like