3. 3
Control Structure
Basic structure of algorithm that
has one or more specific
condition where instruction is
carried out if a condition /
requirement is fulfilled
4. Type of Control Structure
If statement
4
If-else statement
Switch-case statement
if (condition)
{
true statement;
}
if (condition)
{
true statement;
}
else
{
false statement;
}switch(condition)
{
case constant1 : {statement; break}
case constant2 : {statement; break}
.......
}
5. Example of IF Statement
✓ Turn on computer
✓ Find Netbeans app
✓ If Netbeans isn’t available then
✓ Install Netbeans
✓ Write code
✓ Run program
5
6. Example of IF-Else Statement
6
✓ Turn on computer
✓ Check internet connection
✓ Find browser app
✓ If google chrome is available then
✓ Use google chrome
✓ Else
✓ Use others browser
✓ Type URL of SPADA
✓ Use SPADA
7. Example of Switch-Case Statement
Switch nilai
Case 1 : nilai mutu A
Case 2 : nilai mutu B
Case 3 : nilai mutu C
Case 4 : nilai mutu D
Case 5 : nilai mutu E
7
8. Thank You, Next …
Class & Object
Study Program of Informatics
Faculty of Engineering and Computer Science
SY. 2019-2020
Andi Nurkholis, S.Kom., M.Kom.
March 9, 2020