You are on page 1of 11

CD206 BUSINESS PROGRAMMING (Tutorial 1)

ONG ZU NI (1001850786)
Instruction: Answer ALL questions.

1- Draw Problem Analysis Chart (PAC), Interactivity Chart (IC), Input Output
Processing Chart (IPO), Algorithm and Flow Chart for the following questions:

(a) Given the radius r of a sphere, calculate the volume and area of the sphere.
volume = (4/3) * pi * r3
area = 4 * pi * r2

Problem Analysis Chart(PAC)

Given data Required result


r Volume of sphere
Area of sphere
Processing required Alternative Solution
Volume of sphere = (4/3) * pi * r3 1. Define r as constant.
Area of sphere = 4 * pi * r2 *2. Define r as input value.

Interactivity Chart(IC)

MAIN
0000

READ CALC PRINT


1000 2000 3000

CALC_VOLUME CALC_AREA
2100 2200

Input Process Output(IPO)

Inpu Processing Module Reference Output


t
r 1. Read r 1000 Volume of sphere
CD206 BUSINESS PROGRAMMING (Tutorial 1)

2100 Area of sphere


2. Calculate volume 2200
3000
3. Calculate area 0000

4. Print volume and area

5. END

Algorithms and Flowchart

Algorithms Flowchart
Main module
1. Process READ MAIN
2. Process CALC_AREA
3. Process CALC_VOLUME
4. Process PRINT READ
5. END

CALC_AREA

CALC_VOLUME

PRINT

END

Read module
1. READ r READ
2. EXIT

READ r

EXIT
CD206 BUSINESS PROGRAMMING (Tutorial 1)

CALC_VOLUME module
1. Volume = (4/3) * pi * r3 CALC_VOLUME
2. EXIT

Volume = (4/3) * pi * r3

EXIT

CALC_AREA module
1. Area = 4 * pi * r2 CALC_AREA
2. EXIT

Area = 4 * pi * r2

EXIT

Print module
1. PRINT Volume
PRINT
2. PRINT Area
3. EXIT

PRINT VOLUME

PRINT Area

EXIT

(b) Sort THREE (3) integer numbers in ascending order.


Problem Analysis Chart(PAC)

Given Data Required Results


n1, n2, n3 max, min
Processing Required Alternative Solution
1. max = n1 1. Define n1, n2, n3 as constant.
max = n2 *2. Define n1, n2, n3 as input data.
2. identify max value
if n2 > max
max = n2
if n2 > max
max = n3
CD206 BUSINESS PROGRAMMING (Tutorial 1)

3. identify min value


4. if n2 < min
min = n2
if n3 < min
min = n3

Interactivity Chart(IC)

MAIN
0000

READ CALC PRINT


1000 2000 3000

Input Process Output

Input Process Module Reference Output


n1, n2, n3 1. Read n1, n2, n3 1000 max
2. max = n1 min
min = n2 2000
identify max
if n2 > max
max = n2
if n3 > max
max = n3
identify min
if n2 < min
mix = n2
if n3 < min
mix = n3
3. Print max and min
4. END 3000
0000
Algorithms Flowchart
MAIN module
1. Process READ MAIN
CD206 BUSINESS
2. Process CALC PROGRAMMING (Tutorial 1)
3. Process PRINT
4. END READ
F T max
(c) EXIT FFF
n3<min
CALC T min === n2
min n2
n3 P
T max = n3
n2<min CALC
r
i
max = n1 n
PRINT
min = n1 t

END
n2>max
READ module
1. Read n1, n2, n3 READ
2. EXIT
n3>max
READ n1, n2, n3

EXIT

CALC module
1. max = n1
min = n2
2. identify max
if n2 > max
max = n2
if n3 > max
max = n3
3. identify min
if n2 < min
min = n2
if n3 < min
min = n3
4. EXIT

PRINT module
1. Print max and min
PRINT
2. EXIT

Print max and min

EXIT
CD206 BUSINESS PROGRAMMING (Tutorial 1)

the number of days (use 31 days for January / March / July / August / October /
December AND 30 days for April / June / September / November AND 28 days for
February (Non-leap year) AND 29 days for February (Leap year)) between two dates.

Problem Analysis Chart(PAC)

Given Data Required Result


m1, m2 months
d1, d2 days
Processing Required Alternative Solution
1. if d2 > d1 1. Define m1, m2, d1, d2 as constant
days = d2 – d1 + 1 value.
months = m2 – m1 *2. Define m1, m2, d1, d2 as input data.
2. if d1 > d2
days = 30 – d1 + 1 + d2
months = m2 – 1 – m1
3. if d1 = d2
days = 1
months = m2 – m1

Interactivity Chart

MAIN
0000

READ CALC PRINT


1000 2000 3000

Input Process Output(IPO)

Input Process Module Reference Output


m1, m2, 1. Read each months and 1000 months
CD206 BUSINESS PROGRAMMING (Tutorial 1)

d1, d2 days days


2. if d2 > d1 2000
days = d2 – d1 + 1
months = m2 – m1
3. if d1 > d2
days = 30 – d1 + 1 + d2
months = m2 – 1 – m1 2000
4. if d1 = d2
days = 1
months = m2 – m1
5. Print months and days
6. END 2000

3000
0000

Algorithms Flowchart
MAIN module
1. Process READ MAIN
2. Process CALC
3. Process PRINT
4. END READ

CALC

PRINT

END

READ module
1. Read each months and days
2. EXIT
READ

Read each months


and days

EXIT
CD206 BUSINESS PROGRAMMING (Tutorial 1)

CALC module
1. if d2 > d1
CALC
days = d2 – d1 + 1
months = m2 – m1
else
if d1 > d2
days = 30 – d1 + 1 + d2
months = m2 – 1 – m1
else d2>d1
if d1 = d2 days = d2-d1+1 T
days = 1 months = m2-1-
months = m2 – m1 m1

2. EXIT

d1>d2 T
days = 30-d1+1+d2
months = m2-1-m1

d2=d1
T
days = 1
F
CD206 BUSINESS PROGRAMMING (Tutorial 1)

EXIT

PRINT module
1. Print months and days
2. EXIT PRINT

Print months and


days

EXIT

2- Define the following: -


a- problem analysis chart (PAC)
- A problem analysis chart(PAC) helps understanding a problem by separating it
into 4 part, they are:

b- interactivity chart (IC)


- An interactivity chart or structure chart shows the interaction between modules
- Modules refer to the processing which have been divided into subtasks
CD206 BUSINESS PROGRAMMING (Tutorial 1)

- Each module has only one function


- Main or control module controls the flow
- View a complex problem in simpler parts
-
c- Input-Process-Output (IPO)
- IPO chart stand for Input-Process-Output
- An IPO chart organizes information shown in PAC in more details

d- An algorithm
- An algorithm is a set of instructions developed by programmer for a computer
- Setting up an algorithm is challenging as the instructions
 cannot assume anything
 cannot skip steps
 must be executable one step at a time
 must be complete

e- A flowchart
- A flowchart is a graphical representation used to show a step-by-step solution
using symbols which represent a task.

f- A pseudocode
- A pseudocode is an informal way of programming description that does not
require any strict programming language syntax or underlying technology
considerations.

g- Unified Modeling Language (UML)


- UML stands for Unified Modeling Language (UML)
- Used to create a logical model of the solution
- Uses various diagrams to describe the entire system
- Help produce a model of the problem and lead to a better understanding of the
requirements of a problem

3- List FIVE (5) types of UML diagrams.


- Use case diagrams
- Class diagrams
- Sequence diagrams
CD206 BUSINESS PROGRAMMING (Tutorial 1)

- State chart diagrams


- Activity diagrams

END OF QUESTIONS

You might also like