0% found this document useful (0 votes)
284 views15 pages

COMPUTER-PROGRAMMING-12 Q1 W6 Mod6

This document provides instructions and content for a lesson on selection structures in programming. It includes 3 key learning objectives: 1) use standard selection access algorithms for text and binary files, 2) code standard selection access algorithms for text and binary files, and 3) understand which control structure best suits their application. The document defines important terms, provides examples of different selection structures like if-then and if-then-else, and includes activities for students to demonstrate their understanding.

Uploaded by

Allan Yatuhac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
284 views15 pages

COMPUTER-PROGRAMMING-12 Q1 W6 Mod6

This document provides instructions and content for a lesson on selection structures in programming. It includes 3 key learning objectives: 1) use standard selection access algorithms for text and binary files, 2) code standard selection access algorithms for text and binary files, and 3) understand which control structure best suits their application. The document defines important terms, provides examples of different selection structures like if-then and if-then-else, and includes activities for students to demonstrate their understanding.

Uploaded by

Allan Yatuhac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Republic of the Philippines

Department of Education
National Capital Region
DIVISION OF CITY SCHOOLS – MANILA
Manila Education Center Arroceros Forest Park
Antonio J. Villegas St. Ermita, Manila

PROGRAMMING
JAVA NCIII
Grade 12

Quarter 1 Week 6 Module 6


Learning Competency:

APPLYING PROGRAMMING SKILLS IN A SECOND LANGUAGE


TLE_ICTCP9-12PS-Ic-j-1
LESSON 6 – LO 1. APPLY BASIC LANGUAGE SYNTAX AND LAYOUT: USE
THE APPROPRIATE LANGUAGE SYNTAX FOR
SELECTION CONSTRUCTS

1
Division of City Schools-Manila
DEPARTMENT OF EDUCATION
K TO 12 BASIC EDUCATION CURRICULUM JUNIOR HIGH SCHOOL
TECHNICAL LIVELIHOOD EDUCATION AND SENIOR HIGH SCHOOL -
TECHNICAL-VOCATIONAL-LIVELIHOOD TRACK INFORMATION AND
COMMUNICATIONS TECHNOLOGY –PROGRAMMING JAVA NC III

by:
RHAYMOND M. MONTERDE
Master Teacher I
C.P. Garcia High School

2
Before starting the module, I want you to set aside other tasks that will disturb you
while enjoying the lessons. Read the simple instructions below to successfully
enjoy the objectives of this kit. Have fun!
1. Follow carefully all the contents and instructions indicated in every page of this
module and follow the given instructions for each of the given learning outcome/s.
2. As you read, you can also do the hands-on to check if you were able to follow
the basic programming procedure.
3. Demonstrate what you have learned by doing what the Activity required you to
do so.
4. Analyze conceptually the posttest and apply what you have learned.
5. Enjoy studying!

 Expectations - These are what you will be able to know after completing
the lessons in the module.
 Pre-test - This will measure your prior knowledge and the concepts to be
mastered throughout the lesson.
 Technical terms - A word that has a specific meaning within a specific field
of expertise.
 Looking Back to your Lesson - This section will measure what learnings
and skills did you understand from the previous lesson.
 Brief Introduction- This section will give you an overview of the lesson.
 Activities - This is a set of activities you will perform with a partner.
 Remember - This section summarizes the concepts and applications of
the lessons.
 Check your Understanding- It will verify how you learned from the
lesson.
 Post-test - This will measure how much you have learned from the entire
module.

3
TLE_ICTCP9-12PS-Ic-j-1

At the end of the lesson, the students should be able to:


1. use standard selection access algorithms for text and binary files; and
2. code standard selection access algorithms for text and binary files.
3. understand which control structure best suit their application

Arithmetic Operator – is a mathematical function that takes two operands and


performs a calculation on them. They are used in common arithmetic and most
computer languages contain a set of such operators that can be used within
equations to perform a number of types of sequential calculation.

Boolean Condition - are queries that compare two values with each other (e.g.
with == or >=) and then returns the value true or false. A number for example is
evaluated as true if it is greater than 0.

Logical Operator - is a symbol or word used to connect two or more expressions


such that the value of the compound expression produced depends only on that of
the original expressions and on the meaning of the operator.

Two-way or Multi-way selection - is written when there are two sets


of statements: one to be executed when the Boolean condition is true, and another
set for when the Boolean condition is false.

4
To recap, a structured program is a computer program which is implemented
using only those control structures which are found in structured program designs.

a. What is your opinion that makes a program design structured?

b. What is a sequential Structure?

5
Fill in the Table: Fill in the equivalent description for the following operators.

ARITHMETIC/LOGICAL/COMPARISON DESCRIPTION
OPERATOR
(Write your answer here)
1. >
2. ==
3. ++
4. <
5. <>
6. =
7. ≥
8. ≤
9. ≠
10. >=
11. *
12. /
13. +
14. -
15. ^

6
Selection Structure also known as conditional structure or decision structure
is a programming feature that performs different processes based on whether a
boolean condition is true or false. Selection structures use relational operators to
test conditions. There are different types of selection structures that can be used to
achieve different outcomes.
The basic attribute of a selection control structure is to be able to select
between two or more alternate paths. This is described as either two-way
selection or multi-way selection. A question using Boolean concepts usually
controls which path is selected. All of the paths from a selection control structure
join back up at the end of the control structure, before moving on to the next lines
of code in a program.

Selection or Decision Structure

This logical structure is used if you want to analyze whether the given condition or
a couple of conditions are true of false. This structure provides two types of
statements to choose from: If-Then and If-Then-Else statements.

OPERATORS

Flowchart
of Selection
Structure
(decision or
branching
structure)

7
If-Then
This statement enables you to execute a course of action when a condition is met.

DECISION STRUCTURES

• The expression A>B is a logical expression


• it describes a condition we want to test
• if A>B is true (if A is greater than B) we take the action on left
• print the value of A
• if A>B is false (if A is not greater than B) we take the action on right
• print the value of B
Flowchart

Syntax:
If [condition] Then
[statement]
End If

Sample Pseudocode:
If subject is VB.Net Then
Display Form2
End If

8
Sample VB.Net code:
PublicClassForm1
PrivateSub Button1_Click (sender AsObject, e AsEventArgs)
Handles Button1.Click
If TextBox1.Text = “VB.Net” Then
Form2.Show()
EndIf
EndSub

If-Then-Else
This statement enables you to execute another course of action when a condition
is true or false.

IF-THEN-ELSE STRUCTURE
Algorithm
The structure is as follows

If condition then If A>B then


true alternative print A
else else
false alternative print B
endif end if

Flowchart

NESTED IFS
One of the alternatives within an IF-THEN-ELSE statement. May
involve further IF-THEN-ELSE statement.

EXAMPLE: Write an algorithm that reads three numbers and prints the
value of the largest number.

9
Step 1: Input N1,N2,N3
Step 2: if (N1>N2) then
if (N1>N3) then Algorithm
MAX=N1 [N1>N2>,N1>N3]
else
MAX=N3 [N3>N1>N2]
endif
else
if(N2>N3) then
MAX=N2 [N2>N1,N2>N3]
else
MAX=N3 [N3>N2>N1]
endif
endif
Step 3: Print “The largest number is”,MAX

Syntax
If [condition] Then
[statement]
Else
[statement]
End If

Sample Pseudocode:
If grade is greater than or equal to passing Then
Print “Congratulations, You Passed”
Else
Print “Sorry, You Failed”
End If

Sample VB.Net code:


PublicClassForm2
Dim passing AsDouble
PrivateSub Button1_Click (sender AsObject, e AsEventArgs)
Handles Button1.Click
Passing = (60)
If TextBox1.Text >= CDb1 (passing) Then
MessageBox.Show (Congratulations, You Passed”)
Else
MessageBox.Show (Sorry, You Failed”)
EndIf
EndSub
EndClass

Processes will be carried out depending on the result of the condition test.

IF Condition is true THEN


DO Process A
ELSE
DO Process B
ENDIF
10
1. Provide a flowchart that identifies the temperature of tomatoes, if temperature
is less 32 degrees, output cover the tomatoes, otherwise output uncover the
tomatoes.

2. Provide a flowchart that will allow the user to input their age. If they are over
16, output they can drive, otherwise output they can’t drive.

The decision is made as a


result of answering the question
posed in a condition. The
selection control structure consists
of a condition which is either True
or False. In pseudocode, selection
is represented by
the IF, THEN, ELSE, and ENDIF
statements.

11
Direction: Rearrange the letters in the box to form the word that describe the
statement. Write your answer in your quiz notebook.
1. This statement enables you to execute another course of action when
a condition is true or false.

F I - N H E T - E S L E

2. One of the alternatives within an IF-THEN-ELSE statement. May involve


further IF-THEN-ELSE statement.

T S E N E D - F I

3. This statement enables you to execute a course of action when a


condition is met.

IF - H E T N

4. This structure provides two types of statements to choose from: If-Then


and If-Then-Else statements.
E C L S O T N I E

12
Fill in the Table: Fill in the equivalent description for the following operators.

ARITHMETIC/LOGICAL/COMPARISON FUNCTION
OPERATOR
(Write your answer here)
1. >
2. ==
3. ++
4. <
5. <>
6. =
7. ≥
8. ≤
9. ≠
10. >=
11. *
12. /
13. +
14. -
15. ^

13
LESSON 6- Let’s do the checking

Answer Key

a. What is your opinion that makes a program design structured?


Answer: In 1964, Bohm and Jacopini published a paper which demonstrated
that any problem can be solved by using the three logic control structures
of sequence, selection and iteration or repetition. Programs are designed using
common building blocks, known as programming constructs. These programming
constructs form the basis for all programs.
b. What is a sequential Structure?
Answer: Sequential Structure pertains to a step-by step execution of a program.
Also known as straight-line structure, this type of structure follows what is next in
line for the flow of the program.

2
1

14
1. If-Then-Else
2. Nested-If
3. If-Then
4. Selection

Innovative Training Works, Inc. “Computer Programming Volume I” Technical


Vocational Livelihood K to 12 First Edition
https://matlab.enge.vt.edu/selectionstructure.html#:~:text=Also%20known%20as%20
a%20conditional,relational%20operators%20to%20test%20conditions.

http://www.opentextbooks.org.hk/ditatopic/5566

Acknowledgements
Writer: Rhaymond M. Monterde- MT I/ICT Computer Programming
Editors: Ariel Tosio- EPS, Elena C. Reyes- Principal IV, Gibson J.
Olazo– MT II/ICT Computer Programming Coordinator
Reviewer: Gibson J. Olazo– MT II/ICT Computer Programming
Coordinator, Ariel Tosio- EPS
Management Team: Maria Magdalena M. Lim-Schools Division
Superintendent-Manila, Aida H. Rondilla-Chief Education Supervisor
Lucky S. Carpio-EPS and Lady Hannah C Gillo, Librarian II-LRMS

15

You might also like