0% found this document useful (0 votes)
13 views17 pages

PSPD Pbl2 Report-2

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

PSPD Pbl2 Report-2

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

Politeknik Mersing Johor

PBL 2

SEMESTER 1 2024/2025

LECTURER’S NAME : PN SITI ROHANI BINTI SUKAIMI

SUBJECT : PROBLEM SOLVING AND PROGRAM DESIGN

CODE : DFC10252

SUBMISSION DATE : 12/11/2024

PREPARED BY:

MUHAMMAD FATKHUR ROZI BIN BUNYAMIN 25DIT24F1194


AVINASH RAO A/L SREE RAMULU 25DIT24F1064
Table of Contents
Introduction ................................................................................. 2
IPO .............................................................................................. 3
Program Inputs and Logic ........................................................... 5
1. User Inputs: ........................................................................... 5
2. Conditions and Discounts: .................................................... 5
3. Calculation Logic:................................................................. 5
CODE STRUCTURE ................................................................. 6
FULL CODE:............................................................................ 6
OUTPUT EXPLANATION ...................................................... 12
CHALLENGES ........................................................................ 13
Challenges faced during coding: ............................................. 13
REFLECTION .......................................................................... 14
Example .................................................................................... 15
Introduction
The program’s purpose is to create a ticketing system for
Snowalk Indoor I-City Theme Park, where tickets are calculated
based on age categories, and discounts are applied depending on
the group size.

2
IPO

Input:
1. Number of person (Num_person),category (categories),add more ticket(Continue)

Process:
1. enter ticket category

2. compare categories to determine the category ticket and next process

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.2.1.1 if (Num_person >= 5 )


cat2*=0.9

2.3 if not

2.3.1 if (categories == 3)
Num_person = value of Adult tickets entered
cat3 = Num_person * 70.0

2.3.1.1 if (Num_person >= 3 )


3
cat3*=0.95

2.4 if not

2.4.1 if (categories == 4)
Num_person = value of Senior tickets entered
cat4 = Num_person * 56.0

2.4.1.1 if (Num_person >= 3 )


cat4*=0.95

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. if the user choose category 1, if program will be executed

4.1 if(cat1 == 1)
display"your child ticket fee is free"

5. sum up all the category's value


Total_payment = cat2 + cat3 + cat4

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) Categories: The program allows the user to select a category based on


age (1 for children, 2 for teens, 3 for adults, and 4 for seniors).
b) Number of Persons: Depending on the selected category, the user
inputs the number of people.
c) Continue Prompt: Users can choose to add more categories of tickets
by entering "1" to continue or "2" to stop.

2. Conditions and Discounts:

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.

2. Function of using namespace std

a. Contains all the classes, objects and functions of the standard C++ library.

3. Declare identifier and the role

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.

5. Display welcome sign to user

6. Looping (using while loop)

a. Variable that includes


 Continue
b. Scenario: if user enter number 1, the system will key in more.

8
7. Choose the category

a. User has to enter a value to select the ticket category.

8. Selection of category 1,2,3 and 4.


a. Each category has their its condition and process

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

a. The user enters the number of persons.


b. The number of persons will multiply with the base rate.
c. if the value number of persons is greater or equal to 5, the value of the ticket
must be multiplied by 0.9 which is the value after discount.

9
11. Category 3

a. The user enters the number of persons.


b. The number of persons is multiplied by the base rate.
c. if the value number of person is greater or equal to 3, the value of the ticket
must be multiplied by 0.95 which is the value after discount.

12. Category 4

a. The user enters the number of persons.


b. The number of persons is multiplied by the base rate.
c. if the value number of persons is greater or equal to 3, the value of the ticket
will be multiplied by 0.95 which is the value after discount.

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.

15. Output for each category

a. Display the output of each category.

16. Sum all the categories and display

a. All the categories will be added and displayed to the user.

17. Return

a. This system doesn’t return any value.

11
OUTPUT EXPLANATION

1. For each category, the program outputs a message showing the


calculated ticket fee:
a. If a child ticket is selected, it displays that the ticket fee is free.
b. For teens, adults, and seniors, the program shows the ticket fee
after applying any relevant discounts.

1. The total ticket fee is also displayed at the end, summarizing


the payment for all selected categories.

12
CHALLENGES
Challenges faced during coding:

1. Handling user inputs errors


a. If an invalid category is selected, the program informs the user and
continues to the next iteration.

2. Applying discounts
a. Ensuring that discount logic applies correctly for each category based
on the number of tickets.

3. Complexity of loop and conditionals


a. Combining looping with conditionals to handle multiple user inputs
and category selections can be complex, requiring careful tracking of
variables.

13
REFLECTION

1. This project offers a hands-on experience with C++


programming, enhancing understanding of basic programming
concepts like loops, conditionals, and functions.
2. The assignment provides practical insight into managing user
inputs, applying logical conditions, and organizing code
structure for readability and efficiency.
3. It demonstrates how coding can solve real-world problems,
making it an engaging learning experience in problem-based
learning.

14
Example
Category 1

Category 2

Category 3

15
Category 4

Total

16

You might also like