STE Computer Programming Q3 MODULE 3
STE Computer Programming Q3 MODULE 3
Computer
Programming
Quarter III – Module 3:
SWITCH ... CASE STATEMENT
"Designed by macrovector /
Freepik"
"Designed by macrovector /
Freepik"
Computer Programming – Grade 10
Self-Learning Module
First Edition, 2020
Republic Act 8293, section 176 states that: No copyright shall subsist in any work
of the Government of the Philippines. However, prior approval of the government agency or
office wherein the work is created shall be necessary for exploitation of such work for profit.
Such agency or office may, among other things, impose as a condition the payment of
royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names,
trademarks, etc.) included in this module are owned by their respective copyright holders.
Every effort has been exerted to locate and seek permission to use these materials from
their respective copyright owners. The publisher and authors do not represent nor claim
ownership over them.
continue your studies and learn while at home. Activities, questions, directions,
exercises, and discussions are carefully stated for you to understand each lesson.
Each SLM is composed of different parts. Each part shall guide you step-by-
step as you discover and understand the lesson prepared for you.
At the end of each module, you need to answer the test to self-check your
learning. Answer keys are provided for each activity and test. We trust that you will be
In addition to the material in the main text, Notes to the Teacher are also
provided to our facilitators and parents for strategies and reminders on how they can
Please use this module with care. Do not put unnecessary marks on any part of
this SLM. Use a separate sheet of paper in answering the exercises and tests. And
If you have any questions in using this SLM or any difficulty in answering the
Thank you.
Statement!
The hand is one of the most symbolized part of the human body. It is often used to
depict skill, action, and purpose. Through our hands we may learn, create, and
accomplish. Hence, the hand in this learning resource signifies that you as a learner is
capable and empowered to successfully achieve the relevant competencies and skills at
your own pace and time. Your academic success lies in your own hands!
This module was designed to provide you with fun and meaningful opportunities for
guided and independent learning at your own pace and time. You will be enabled to
process the contents of the learning resource while being an active learner.
this module.
1. Use the module with care. Do not put unnecessary mark/s on any part of the
3. Observe honesty and integrity in doing the tasks and checking your answers.
5. Return this module to your teacher/facilitator once you are through with it.
If you encounter any difficulty in answering the tasks in this module, do not hesitate
to consult your teacher or facilitator. Always bear in mind that you are not alone.
We hope that through this material, you will experience meaningful learning and
Introduction:
Control statements halt the program execution from going to the next sequential
statement and can shift the execution to another statement, which need not be the
next statement in the sequential order. They assist us in making programmed decisions
and processing the information as necessary.
Sub-Task:
I. TRUE or FALSE. Write TRUE when the statement is correct; write FALSE when the
statement is an error. Write your answers on a separate paper.
“Break” or “Exit”.
10. The last case for this statement would be the Default statement,
This statement is the most useful control statement for programmed decision
making.
some programming languages, the entire If ... Then ... Else ... statement is written on
the same line. But in most programming languages, the If statement spans across
The activity shows four (4) pictures, you have to guess what the pictures meaning or
symbolises in one word.
Switch <Variable>
Case a
Statement
Statement
Case b
Statement
Statement
Case n
Statement
Statement
Default
Statement
Statement
Endcase
In the earlier statement, a, b, and n are the values for the variable
specified in the Switch statement.
7. The last case for this statement would be the Default statement, which
specifies the action to be taken when the value of the variable does not
match any value specified in all the Case statements.
10. The last of the statements under each Case would usually be a “Break”
or “Exit” statement. It would be usually the only word in that statement.
The execution of Break (or Exit) statement would take the execution to
the statement that immediately follows the Endcase statement.
Switch ... Case statement is used when there is a need for making a decision
based on one condition that can have multiple outcomes. We use If statement when the
decision has one or two possible outcomes. When the possible outcomes are numerous,
we use Switch ... Case statements. When converting from numbers to strings, this
statement comes in handy. Switch ... Case statements also come in handy when we are
developing software packages such as MS-Word, where in the character being typed in
can lead to any one of a variety of different actions.
It is essential to use the Break (or Exit) statement at the end of the statements
in every Case block. Most often, programmers tend to neglect the Break statement in
the last block of Case statements. It is also common to forget the Break statement in
the Default block of statements. Break forces the execution to go outside the Switch
block of statements. While writing computer programs, we need to remember that the
program will certainly undergo modification or enhancement. We are likely to add a
Switch MonthNumber
Case 1
MonthString = “January”
Break
Case 2
MonthString = “February”
Break
Case 3
MonthString = “March”
Break
Case 4
MonthString = “April”
Break
Case 5
MonthString = “May”
Break
Case 6
MonthString = “June”
Break
Case 7
MonthString = “July”
Break
Case 8
MonthString = “August”
Break
Case 9
MonthString = “September”
Break
Case 10
MonthString = “October”
Break
Case 11
MonthString = “November”
Break
Case 12
MonthString = “December”
Output:
Enter month number: 4
Month name is: April
Engage
Activity 1: Name 3 programming languages that uses the Switch… Case Statement and
write their syntax. Use the table below in answering.
95 – 100 Outstanding
90 – 94 Very Satisfactory
85 – 89 Satisfactory
80 – 84 Very Good
75 – 79 Good
60 – 74 Failed
2. Write a simple program that display the name of the week according
to the number that corresponding the day.
To score these activity rubrics is being used. Follow the rubrics criteria for your
guidance.
Assess
I encountered difficulties in