COMP6598 - Week 1 - Introduction To Algorithm and Java Programming
COMP6598 - Week 1 - Introduction To Algorithm and Java Programming
Introduction to Programming
BEGIN
Number = Input Number
Result = Number % 2
IF Result = 0
THEN Print “The number is even number”
ELSE
THEN Print “The number is odd number”
END
FLOWCHART
Flowchart
• Schematic representation of process or algorithm.
• Schematic is a illustration of system in simplified or symbolic
form.
Flowchart Symbols
NS DIAGRAM
NS Diagram
• NS Diagram is a graphical illustration of structured
progamming design.
• Its method is by drawing a table for illustrating an algorithm.
• Founded in 1972 by Isaac Nassi & Ben Shneiderman.
• Known as structograms.
NS Diagram
• Process notation : Process
Process
– DO-WHILE Unfulfilled
Condition
NS Diagram
• Example of NS Diagram to determine odd-even
numbers
Insert number
Number %Equal
2 to 1
Equal to 0
Welcome.java Welcome.class
Java
(Java source (Java bytecode JVM
code file) Compiler executable fle)
Compiled by generates Executed by
CREATING, COMPILING, AND
EXECUTE
Creating, Compiling, &
Executing
Create/Modify Source Code
Source code (developed by the programmer)
public class Welcome { Save on the
Public static void main(String [] args) disk
{ Source Code
System.out.println(“Welcome to Java!”);
}
}
Compile Source Code
e.g., javac Welcome.java
… Bytecode
Method Welcome()
0 aload_0
If runtime
… errors or
Run Bytecode
Incorrect
Method void main(java.lang.String[]) e.g., java Welcome result
0 getstatic #2 …
3 ldc #3 <String “Welcome to Java!”>
5 invokevirtual #4
Result
8 return
EXERCISE
Exercise
1. From the following pseudocode example of grade average
calculation, create the flowchart and NS Diagram
BEGIN
read balloons
DOWHILE balloons is greater than zero
Print “i have “, balloons
ballons = ballons - 1
ENDDO
END
Exercise