COMPUTER-PROGRAMMING-12 Q1 W6 Mod6
COMPUTER-PROGRAMMING-12 Q1 W6 Mod6
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
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
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.
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.
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.
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
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
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
Processes will be carried out depending on the result of the condition test.
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.
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
T S E N E D - F I
IF - H E T N
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
2
1
14
1. If-Then-Else
2. Nested-If
3. If-Then
4. Selection
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