PSPD Pbl2 Report-2
PSPD Pbl2 Report-2
PBL 2
SEMESTER 1 2024/2025
CODE : DFC10252
PREPARED BY:
2
IPO
Input:
1. Number of person (Num_person),category (categories),add more ticket(Continue)
Process:
1. enter ticket category
2.1 if (categories == 1)
Num_person = value of Child tickets entered
cat1 = 1
2.2 if not
2.2.1 if (categories == 2)
Num_person = value of Teen tickets entered
cat2 = Num_person * 60.0
2.3 if not
2.3.1 if (categories == 3)
Num_person = value of Adult tickets entered
cat3 = Num_person * 70.0
2.4 if not
2.4.1 if (categories == 4)
Num_person = value of Senior tickets entered
cat4 = Num_person * 56.0
3. enter value 1to Continue if user want to add more tickets and if user has done adding
tickets, the user can enter number 2
3.1 while(Continue == 1)
4.1 if(cat1 == 1)
display"your child ticket fee is free"
Output:
1. display"Your Teen ticket fee is Rm " and value of cat2
2. display"Your Adult ticket fee is Rm " and value of cat3
3. display"Your Senior ticket fee is Rm " and value of cat4
4. display"Your Total ticket fee is Rm " and value of Total_payment
4
Program Inputs and Logic
1. User Inputs:
a) Children (Category 1): Ticket is free for children aged 11 and below.
b) Teens (Category 2): Each ticket costs RM60, and if 5 or more tickets
are purchased, there is a 10% discount.
c) Adults (Category 3): Each ticket costs RM70, and if 3 or more tickets
are purchased, there is a 5% discount.
d) Seniors (Category 4): Each ticket costs RM56, with a 5% discount if
3 or more tickets are purchased.
3. Calculation Logic:
a. Each category has a different formula for ticket calculation. The total
price for each category is calculated based on the number of tickets
and discount conditions if they apply.
5
CODE STRUCTURE
FULL CODE:
6
1. Declare the standard header file
a. Perform input from the keyboard and text output to the screen.
a. Contains all the classes, objects and functions of the standard C++ library.
a. int (integer)
Num_person = keeps the value for number of persons.
categories = keeps the value for category selection.
Continue = keeps the value for looping.
7
4. Declare identifier and the role
a. float (Float)
Total_payment = keeps the value of the sum operation for all categories.
cat(1-4) = keeps the value of ticket fee for each category.
8
7. Choose the category
9. Category 1
a. On this selection, the user has to key in the number of children and then this
category has a set value of cat1 to 1 to trigger the output of category 1.
10. Category 2
9
11. Category 3
12. Category 4
13. Else
a. If the user puts other values for categories which are (1, 2, 3, and 4), this will
make the user to re-enter the value again.
10
14. Trigger loop
a. This syntax will ask the user if they want to add more people or not which
means if the user enters 1 the system will loop to the first line in do while. if
the user enters 2 the system will go to the next step.
17. Return
11
OUTPUT EXPLANATION
12
CHALLENGES
Challenges faced during coding:
2. Applying discounts
a. Ensuring that discount logic applies correctly for each category based
on the number of tickets.
13
REFLECTION
14
Example
Category 1
Category 2
Category 3
15
Category 4
Total
16