Professional Documents
Culture Documents
PROGRAM CONTROL
STRUCTURE (Part 2)
By end of this class :
If a=3, b = 5
a=b would give a new value
which is 5
≠ If a=3, b = 5
a==b would return a FALSE value
Class Activity
In group of TWO :
1. Write algorithm
2. Convert into
program code
using given
selection
statement
Activity 1
Activity 1
multiple if statement
Write a program to test the input of
TWO numbers.
i. Print the message "SAME" if the two numbers have
Tips: equal value.
Use the
simple logical
ii. Print the message "THE FIRST NUMBER IS BIGGER" if
operators the first number is greater than the second number.
that you have iii. Print the message "THE SECOND NUMBER IS BIGGER"
learn. if the second number is greater than the first number.
(<,>, <=, =>,
==,! =)
Class Activity
In group of TWO :
1. Write algorithm
2. Convert into
program code
using given
selection
statement
Activity 2
Activity 2
multiple if statement
Write a program using multiple if statement to
receive grade from a user and display the output as
below
Grade Message
A Min marks is 80
B Min marks is 60
C Min marks is 40
D Min marks is 25
Ungraded Min marks is 0-24
Class Activity
In group of TWO :
1. Write algorithm
2. Convert into
program code
using given
selection
statement
Activity 3
Activity 3
nested if statement
Write a program using nested if statement to receive
grade from a user and display the output as below
Grade Message
A Min marks is 80
B Min marks is 60
C Min marks is 40
D Min marks is 25
Ungraded Min marks is 0-24
Class Activity
In group of TWO :
1. Write algorithm
2. Convert into
program code
using given
selection
statement
Activity 4
Activity 4
switch statement
Write a program using switch statement to receive
grade from a user and display the output as below
Grade Message
A Min marks is 80
B Min marks is 60
C Min marks is 40
D Min marks is 25
Ungraded Min marks is 0-24
Exercise