Professional Documents
Culture Documents
Exercise 1
-- IF STATEMENT --
PSEUDOCODE
Start
Enter “Please enter your age”
Display age
If age > 20
Display “You are eligible to vote”
EndIf
End
FLOWCHART
C++
Exercise 2
-- IF...ELSE STATEMENT --
A system to check the eligibility of a person to vote during the
election. The input for the system is the person's age. If the
age is greater than 20 years old, display "You are eligible to
vote" message. If not, display "You are not eligible to vote"
message. Develop pseudo code and flowchart for the
statement below.
PSEUDOCODE
Start
Enter “Please enter your age”
Display age
If age > 20
Display “You are eligible to vote”
Else
Display “You are not eligible to vote”
EndIf
End
FLOWCHART
C++
Exercise 3
-- IF...ELSE STATEMENT --
PSEUDOCODE
Start
Enter “Please enter your age”
Display age
If (age < 18)
Display “ You are too young to work”
Else if (age > 60)
Display "You are too old to work”
Else
Display “You are eligible to work”
EndIf
End
FLOWCHART
FALSE
C++
Exercise 4
-- NESTED IF STATEMENT --
PSEUDOCODE
Start
Get nationality
Enter “Please enter your nationality”
Display nationality
If nationality == “Malaysia”
Enter “Please enter your age”
Display age
If (age > 20)
Display “You are eligible to vote”
Else
Display “You are too young to vote”
Else
Display “You are not eligible to vote"
EndIf
End
FLOWCHART
C++
Exercise 5
Write a program that receive temperature as input. If
temperature is 80 degrees or more, display message that
telling the user to go to swimming. Otherwise, if temperature
is 50 degrees or more, display message to go to running,
otherwise stay inside the house.
PSEUDOCODE
Start
Enter “Please enter the temperature”
Display temperature
If (temperature >= 80)
Display “Go to swimming”
Else if (temperature >= 50)
Display “Go to running”
Else
Display “Stay inside the house”
EndIf
End
FLOWCHART
FALSE
C++
Exercise 6
A system to check the size of the shirt in store. There are three
code size which are ‘S’, ‘M’ and ‘L’. The storekeeper needs to
enter the code size in system. If the size is ‘S’, display “Small
size” message. If the size is ‘M’, display “Medium size”
message. If the size is ‘L’, display “Large size” message. If
not display “Invalid code” message.
PSEUDOCODE
Start
Enter “Please enter your shirt size”
Display size
If ( size == ‘S’)
Display “Small size”
Else if ( size == ‘M’)
Display “Medium size”
Else if ( size == ‘L’)
Display “Large size”
Else
Display “Invalid code”
EndIf
End
FLOWCHART
C++
Exercise 7
Write a program that receive temperature input based on
weather condition. User need to enter the weather condition
first. If weather condition is equivalent to “Sunny”, then user
need to enter the temperature. If the temperature is between
78 to 82 degrees, display “Go to swim” message. Otherwise
display “Stay inside” message. If weather is equivalent to
“Rainy”, display “Not suitable to swim” message.
PSEUDOCODE
Start
Get weather condition
Enter “Please enter the weather condition”
Display weather
If weather == “Sunny”
Enter “Please enter the temperature”
Display temperature
If (temperature >= 78 && temperature <=82)
Display “Go to swim”
Else
Display “Stay inside”
FLOWCHART
C++