When you use a mobile app, it does not behave exactly the same way every time.
It responds based on what you do.
For example, when you enter the correct password in WhatsApp, it opens your chats.
But when you enter the wrong password, it refuses to open.
This happens because the app is using conditional statements.
Conditional statements help the app decide what to do based on a situation.
In programming, a condition is something that can be either true or false.
The program checks whether the condition is true or false, and then decides what action to take.
Conditional statements are one of the most important parts of programming because they allow apps to make decisions.
Without conditional statements, apps would not be intelligent or useful.
Β
CLICK HERE TO LISTEN
Examples of Conditions
You already use conditions every day in your life.
For example:
If it is raining, you carry an umbrella.
If it is not raining, you do not carry an umbrella.
The condition is: It is raining.
If true, carry umbrella.
If false, do nothing.
Another example:
If your phone battery is low, you charge it.
If your phone battery is full, you do not charge it.
Another example in school:
If you pass UNEB exams, you join the next level.
If you fail, you repeat or take another path.
These are all conditional decisions.
Apps work in the same way.
Example in Mobile Apps
Example: Login system
If the password is correct
then open the app
Else
show error message
This protects the system.
Example: School fees app
If savings reach target
then show success message
Else
encourage user to save more
Understanding Conditional Blocks in App Inventor
In MIT App Inventor, conditional blocks are found in the Control section.
There are three main types:
1. IF block
Structure:
if condition then
This means:
If the condition is true, the code runs.
If the condition is false, nothing happens.
Example:
If savings = 50,000 UGX
then show message “Goal reached”
2. IF-ELSE block
Structure:
if condition then
else
This gives two options.
Example:
If password is correct
then open app
else show error
This is useful when you want something to happen whether condition is true or false.
3. IF-ELSE IF-ELSE block
This allows checking multiple conditions.
Example:
If savings > 100,000
then show “Excellent”
Else if savings > 50,000
then show “Good”
Else show “Keep saving”
This helps apps give different responses.
Important Rule: Order Matters
The order of conditions is very important.
Once a true condition is found, the rest are ignored.
Example:
If marks > 90
then Grade A
Else if marks > 70
then Grade B
Else Grade C
If marks are 95, Grade A shows immediately.
It does not check others.
ICT Club Practical Example: School Fees Saving App
Let us build a simple savings app.
The app helps students save school fees.
Condition example:
If savings β₯ 500,000 UGX
then show “You are ready for school”
Else
show “Continue saving”
This helps students track progress.
Another Example: Electricity Token App
Condition:
If token is correct
then activate power
Else
show error
This is similar to Umeme system in Uganda.
Coding Example: Counting Game
The Counting Game is a simple game.
Players add numbers.
Goal is to reach exactly 100.
Condition:
If total = 100
then show “You win”
Else if total > 100
then show “You lose”
Else
continue game
This makes the game intelligent.
Challenge Activity: Reset Button
Add a Reset Button.
Condition:
If Reset button clicked
then set total = 0
This allows player to start again.
Daily Life Reflection Activity
Think about your daily decisions.
Example:
If it is cold in Kabale
then wear sweater
Else
wear normal clothes
Example:
If your data bundle is finished
then buy new bundle
Else
continue browsing
These are conditional decisions.
Β (ICT Club Project)
Build a simple Login App in MIT App Inventor.
Components needed:
TextBox for password
Button for login
Label for result
Condition:
If password = “1234”
then show “Access Granted”
Else
show “Access Denied”
Test with students.
Improve the app.
Why Conditional Statements are Important
Conditional statements make apps intelligent.
They allow apps to respond to users.
They improve security.
They improve user experience.
They allow games, login systems, saving apps, and many others to work.
Without conditionals, apps cannot make decisions.
Β ExamplesΒ
School Fees App
If fees complete β show success
Boda Safety App
If rider verified β show safe
School Notes App
If internet available β download notes
Else β show offline notes
Key Terms
Condition
A situation that can be true or false.
Example: Is password correct?
Conditional Statement
Code that makes decision.
Example: If password correct β open app
If-Else
Two options.
True β do this
False β do that
Summary
Conditional statements help apps make decisions.
They check conditions.
They perform actions based on results.
They are used in all apps.
They make apps useful.
Every intelligent app uses conditionals.
ICT Club Project Assignment
Create your own app using conditionals.
Examples:
School Fees Tracker
Login App
Quiz App
Savings App
Test it with students.