01 - 02 - COMP6047 - Algorithm - Programming
01 - 02 - COMP6047 - Algorithm - Programming
Syntax Err
Executable code:
=> Run
Output Err
6
Documentation
COMP6047 - Algorithm and Programming
Algorithm Development Steps
Problem Model Algorithm Writing Code
Definition Development Design
COMPILE
Problem:
Syntax Err
Finding the solution or root of quadratic
equation
Executable code:
=> Run
Definition:
Quadratic equation : ax^2 + bx + c = 0
Output Err
Data needed:
Coefficient of a, b and c : real type
Documentation
COMPILE
Syntax Err
Mathematical model:
Quadratic formula:
Executable code:
x1 = (-b + sqrt(b^2 - 4ac))/2a => Run
Documentation
Start COMPILE
Input a,b,c
Syntax Err
d = b^2 – 4ac
Executable code:
=> Run
Y
d<0
T Output Err
x1=(-b+sqrt(d))/2a Print:
x2 =(-b-sqrt(d))/2a “Imaginary”
Documentation
Print : x1, x2
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
COMPILE
Syntax Err
Executable code:
=> Run
Output Err
Documentation
• Example:
Read bilangan
Get tax_code
Baca students_name
• Example:
Print “Bina Nusantara University”
Write “Algorithm and Programming”
Output Total
• Example:
Add number to total
Total = Total + number
• Example:
Set Counter to 0
Total = Price * Qty
• Example:
IF Menu=‘1’ THEN
Discount = 0.1 * price
ELSE
Discount = 0.2 * price
ENDIF
• Example:
DOWHILE number < 10
print number
number = number +1
ENDDO
• Description
Sequence of command is from the 1st line to the end of code. If
newStudent input is 2 then total that later on printed out is 51
• Description
The word “Monday” will be printed out if Day’s value equal
to 1, else it will print out the sentence “Obviously not
Monday”.
• Description
At first Stars’ value equals to 0, after following the DOWHILE
looping Stars’ value will be updated 5 times resulting:
01234