Source
Source
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
by:
GIBSON J. OLAZO
Master Teacher II
Jose Abad Santos High School
Senior High School
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.
TLE_ICTCP9-12PS-IIa-b-2
2. Finding your starting and ending point are crucial to listing the steps of
the process. To determine a starting point, determine the answer to these
questions, except?
A. What data/inputs are available?
B. Where is that data located?
C. What facts will we learn from the process?
D. What formulas are applicable to the issue at hand?
3. As with the starting point, you can find the end point of your algorithm
by focusing on these questions, except?
a. What facts will we learn from the process?
b. What changes from the start to the end?
c. What will be added or no longer exist?
d. How do the data values relate to each other?
4. To use a real-world example, let’s say your goal is to have lasagna for
dinner. You’ve determined that the starting point is to find a recipe, and
that the end result is that you’ll have a lasagna fully cooked and ready
to eat by 7 PM. What will you do?
a. Determine how will you accomplish each step.
b. List the steps from start to finish.
c. Find the ending point of the algorithm.
d. Determine the outcome of your code.
5. Now that you’ve written your algorithm, it’s time to evaluate the process
by?
a. Review the algorithm.
b. List the steps from start to finish.
c. Find the ending point of the algorithm.
d. Determine how will you accomplish each step.
Intelligence is one of the key characteristics which differentiate a human
being from other living creatures on the earth. Basic intelligence covers day
to day problem solving and making strategies to handle different situations
which keep arising in day to day life. One person goes Bank to withdraw money.
After knowing the balance in his account, he/she decides to withdraw the entire
amount from his account but he/she has to leave minimum balance in his
account. Here deciding about how much amount he/she may withdraw from
the account is one of the examples of the basic intelligence. During the process
of solving any problem, one tries to find the necessary steps to be taken in a
sequence. In this unit, you will develop your understanding about problem
solving and approaches.
Problem solving is a part of our daily life. In computer programming, problem
solving is inevitable too and it is one of the main reasons why a program is
created. You can think of a programming algorithm as a recipe that describes
the exact steps needed for the computer to solve a problem or reach a goal.
We've all seen food recipes - they list the ingredients needed and a set of steps
for how to make the described meal. Well, an algorithm is just like that. In
computer lingo, the word for a recipe is a procedure, and the ingredients are
called inputs. Your computer looks at your procedure, follows it to the letter, and
you get to see the results, which are called outputs. A programming algorithm
describes how to do something, and your computer will do it exactly that way
every time. Well, it will once you convert your algorithm into a language it
understands!
However, it's important to note that a programming algorithm is not computer
code. It's written in simple English (or whatever the programmer speaks). It
doesn't beat around the bush--it has a start, a middle, and an end. In fact, you will
probably label the first step 'start' and the last step 'end.' It includes only what
you need to carry out the task. It does not include anything unclear, often called
ambiguous in computer lingo, that someone reading it might wonder about.
In this lesson, we will learn the various concepts on how to plan a program’s
output, step by step using algorithm.
WHAT IS AN ALGORITHM?
Generally, an algorithm is a step-by-step procedure to solve problems. A guide
for isntalling new software, a manual for assembling appliances, and even recipes
are examples of an algorithm. In programming, making an algorithm is exciting, they
are expressed in a programming language or in a pseudocode.
Algorithm makes the whole procedure more efficient as well as consistent. It also
helps in identifying decision points, processes, and essential variables to solve the
problem. A programmer can also see and determine easily the errors in a particular
process using an algorithm.
PROGRAMMING ALGORITHM
You probably wish you could see an example, right? So, what exactly does an
algorithm in programming look like? Well, asking a user for an email address is
probably one of the most common tasks a web-based program might need to do, so
that is what we will use here for an example. An algorithm can be written as a list of
steps using text. We will make one of each which you will see here:
Wasn't that easy? Notice how the top of our example is just a numbered list of
steps using plain English, stating exactly what we want the procedure to do (no
more, no less). That's a nice thing here, because in one of our steps (step 7) a
decision must be made and, depending on the result of that decision, our steps may
not go in order from start to end.
Let's take a quick run through our little recipe:
1. Step 1 is really just a reminder that this is a procedure with a beginning and
an end.
2.In step 2, we make a place in the computer to store what the user types in, also
called a variable
3.In step 3, we clear this variable because we might need to use it again and don't
want the old contents mixed in with the new.
4. In step 4, we prompt the user for an email address
5. In step 5, we stick it in our nifty variable.
6.In step 6, we tell our computer to take a close look at this email address-- is it
really an email address?
ALGORITHM EXAMPLES
.
Algorithm
EXAMPLE 2: Write an algorithm that will read the two sides of a rectangle and
calculate its area.
Algorithm
Step 1: Input W,L
Step 2: A=LxW
Step 3: Print A
1. Write an algorithm to print 1 to 20.
4. Write an algorithm that reads two values, determine the largest value and
prints the largest value with an identifying message.
An algorithm shows
you every step of
reaching the final
solution. An
algorithm uses
mainly words to
describe the steps to
make the process
understandable.
2. Finding your starting and ending point are crucial to listing the steps of
the process. To determine a starting point, determine the answer to these
questions, except?
A. What data/inputs are available?
B. Where is that data located?
C. What facts will we learn from the process?
D. What formulas are applicable to the issue at hand? E.
3. As with the starting point, you can find the end point of your algorithm
by focusing on these questions, except?
A. What facts will we learn from the process?
B. What changes from the start to the end?
C. What will be added or no longer exist?
D. How do the data values relate to each other?
4. To use a real-world example, let’s say your goal is to have lasagna for
dinner. You’ve determined that the starting point is to find a recipe, and
that the end result is that you’ll have a lasagna fully cooked and ready
to eat by 7 PM. What will you do?
A. Determine how will you accomplish each step.
B. List the steps from start to finish.
C. Find the ending point of the algorithm.
D. Determine the outcome of your code.
5. Now that you’ve written your algorithm, it’s time to evaluate the
process by?
A. Review the algorithm.
B. List the steps from start to finish.
C. Find the ending point of the algorithm.
D. Determine how will you accomplish each step.
LESSON 1 - Let’s do the checking
Answer Key
Acknowledgements
Writer: Gibson J. Olazo- MTII
Editors: Ariel Tosio-EPS, Vladimir B. Paraiso-Assistant Principal
PROGRAMMING
JAVA NCIII
Grade 12
by:
GIBSON J. OLAZO
Master Teacher II
Jose Abad Santos High School
Senior High School
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.
TLE_ICTCP9-12PS-IIa-b-2
Syntax - is the set of rules that defines the combinations of symbols that are
considered to be a correctly structured document or fragment in that language.
It always leads to a solution and tries to be the most efficient solution we can
think up. It's often a good idea to number the steps, but you don't have to.
Instead of numbered steps, some folks use indentation and write in pseudocode,
which is a semi-programming language used to describe the steps in an
algorithm. But, we won't use that here since simplicity is the main thing.
Before you write one piece of computer code, you have to know what the
program is supposed to do. Before you write one line of code in any language, it
is a good idea to write it in a simple way first to ensure you have included
everything you need. The best way to set this up is by using pseudocode.
WHAT IS A PSEUDOCODE?
A pseudocode is a description of an algorithm or a computer program using
natural language. Because the aim of pseudocode is to make reading program
easier, some codes that are not essential for human understanding are
omitted. This language is commonly used in planning out structure of a program or
a system, like the blueprint for creating a house or a building.
A pseudocode is a simple way of writing programming code in English.
Pseudocode is not actual programming language. It uses short phrases to write
code for programs before you actually create it in a specific language. Once you
know what the program is about and how it will function, then you can use
pseudocode to create statements to achieve the required results for your program.
To use pseudocode, all you do is write what you want your program to say in
English. Pseudocode allows you to translate your statements into any language
because there are no special commands and it is not standardized. Writing out
programs before you code can enable you to better organize and see where you
may have left out needed parts in your programs. All you have to do is write it out in
your own words in short statements. Let's look at some examples.
EXAMPLES OF PSEUDOCODE
1. Create a program to add 2 numbers together and then display the result.
Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program
2. Compute the area of a rectangle.
Get the length, l, and width, w
Compute the area = l*w
Display the area
3. Compute the perimeter of a rectangle.
Enter length, l
Enter width, w
Compute Perimeter = 2*l + 2*w
Display Perimeter of a rectangle
Choose a simple task to accomplish with your program. You want this to be
complex enough to require multiple steps while still being relatively simple to
accomplish. Some ideas are:
o Walk across a room
o Find the difference between two numbers
o Determine if a number is even or odd
After you have written your pseudocode program, put it aside for at least 1
day (more is better).
o The act of resting the ideas you have written will help you to edit your
work more accurately later.
When you are ready, try to follow your program exactly.
o Did you accomplish the task?
o If you were not successful in completing the task, trouble shoot your
program to find out why.
You have likely left out a small step that seemed logical to you
as
you were writing the code, but needed to be spelled out to get
If you neededan to accurate program.
do any trouble shooting, wait another day or two before
testing
youro code again. to test until you successfully include all steps required to
Continue
complete your task.
Alternatively, you can ask someone to attempt to complete your task following
your pseudocode precisely.
o Troubleshoot as described above.
1. Write a pseudocode to convert the length in feet to centimeter.
2. Write pseudocode that will read the two sides of a rectangle and calculate
its area.
Answer Key
Pseudocode Pseudocode
1
3
Input the length in feet (Lft) Input the coefficients (a,b,c) of
Calculate the length in cm the quadratic equation
(Lcm) by multiplying Lft with Calculate d
30
Calculate x1
Print length in cm (Lcm)
Calculate x2
Print x1 and x2
2 Pseudocode
Acknowledgements
Writer: Gibson J. Olazo- MTII
Editors: Ariel Tosio-EPS, Vladimir B. Paraiso-Assistant Principal
PROGRAMMING
JAVA NCIII
Grade 12
by:
GIBSON J. OLAZO
Master Teacher II
Jose Abad Santos High School
Senior High School
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.
TLE_ICTCP9-12PS-IIa-b-2
5. Use for any I/O operation. Indicates that the computer is to obtain data or
output results.
a. Input/Output d. Flow lines
b. Off page connector e. Decision
c. On page connector
Flowcharts to document business processes came into use in the 1920s and
‘30s. In 1921, industrial engineers Frank and Lillian Gilbreth introduced the “Flow
Process Chart” to the American Society of Mechanical Engineers (ASME). In the
early 1930s, industrial engineer Allan H. Morgensen used Gilbreth’s tools to
present conferences on making work more efficient to business people at his
company. In the 1940s, two Morgensen students, Art Spinanger and Ben S.
Graham, spread the methods more widely. Spinanger introduced the work
simplification methods to Procter and Gamble. Graham, a director at Standard
Register Industrial, adapted flow process charts to information processing. In
1947, ASME adopted a symbol system for Flow Process Charts, derived
from the Gilbreths’ original work.
Also in the late ‘40s, Herman Goldstine and John Van Neumann
used flowcharts to develop computer programs, and diagramming soon
became increasingly popular for computer programs and algorithms of all kinds.
Flowcharts are still used for programming today, although pseudocode, a
combination of words and coding language meant for human reading, is
often used to depict deeper levels of detail and get closer to a final product.
In Japan, Kaoru Ishikawa (1915-1989), a key figure in quality initiatives in
manufacturing, named flowcharts as one of the key tools of quality control, along
with complementary tools such as the Histogram, Check Sheet and Cause-and-
Effect Diagram, now often called the Ishikawa Diagram.
For years, flowcharts were used to map out programs before writing one line
of code in a language. However, they were difficult to modify and with
the advancement of programming languages, it was difficult to display all parts
of a program with a flowchart.
A flowchart is a type of diagram that represents an algorithm, workflow or
process. The flowchart shows the steps as boxes of various kinds, and their order
by connecting the boxes with arrows. This diagrammatic representation illustrates
a solution model to a given problem. Flowcharts are used in analyzing, designing,
documenting or managing a process or program in various fields.
WHAT IS A FLOWCHART?
Like pseudocodes, flowchart is also a description of an algorithm or a computer
program. It also serves as the programs blueprint during the Program Development
Process. The difference is that flowchart is a graphical representation of it.
Flowcharts help in the effective analysis of the problem as well as the application’s
or program’s maintenance, thus providing ease in identifying potential improvements
of the system or program.
It consists of 8 standard symbols namely: Terminal, Preparation/Initialization,
Process, Decision, On-page Connector, Off-page Connector, Input/Output operation,
and Flow lines (arrow).
FLOWCHART SYMBOLS
A FLOWCHART
shows logic of an algorithm
emphasizes individual steps and their interconnections
e.g. control flow from one action to the next
EXAMPLES OF FLOWCHART
Start
Read
Temperatur
N
Print “Above
Temperature<=0
Freezing”
Y
A
Print “Below
Freezing”
End
2. Draw a flowchart to convert the length in feet to centimeter
Flowchart
3. Draw a flowchart that will read the two sides of a rectangle and calculate its
area.
Flowchart
1. Draw a flowchart to find the area of a circle: Area=3.14*r*r
2. Draw a flowchart which gets two number and prints sum of their
value.
7. Draw a flowchart that reads two values, determine the largest value and
prints the largest value with an identifying message.
8.Draw a flowchart that will calculate the roots of a quadratic equation
ax2+bx+c=0.
Hint: d=sqrt(b2-4ac), and the roots are: x1=(-b+d)/2a and x2=(-b-d)/2a
. A flowchart shows
you how to carry out
the process by
connecting each step.
A flowchart uses the
help of symbols,
shapes and arrows to
make the process
Direction: Write your understanding about the following:
Answer Key
1.C
2.D
3.A
4.E
5.A
2. Convert
the length
in feet to
centimeter
Input the length in feet (Lft)
Answer:
Calculate the length in cm
Pseudocode
(Lcm) by multiplying Lft with
30
Print length in cm (Lcm)
5
2
6
7
8 Flowchart
Flowchart consist of 8 standard symbols. Draw and name the 8 standard symbols
Answer:
Innovative Training Works, Inc. “Computer Programming Volume I” Technical
Vocational Livelihood K to 12 First Edition
https://uomustansiriyah.edu.iq/media/lectures/5/5_2016_03_22!07_06_46_PM.pdf
https://www.edrawsoft.com/explain-algorithm-flowchart.html
https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial
Acknowledgements
Writer: Gibson J. Olazo- MTII
Editors: Ariel Tosio-EPS, Vladimir B. Paraiso-Assistant Principal
PROGRAMMING
JAVA NCIII
Grade 12
by:
GIBSON J. OLAZO
Master Teacher II
Jose Abad Santos High School
Senior High School
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.
TLE_ICTCP9-12PS-IIa-b-2
2 3
4 5
6
7
8
When creating a variable, we also need to declare the data type it contains.
This is because the program will use different types of data in different ways.
Programming languages define data types differently. For example, almost all
languages differentiate between ‘integers’ (or whole numbers, eg 12), ‘non-
integers’ (numbers with decimals, eg 0.24), and ‘characters’ (letters of the
alphabet or words).
In computer science and computer programming, a data type or simply type
is an attribute of data which tells the compiler or interpreter how the
programmer intends to use the data. This data type defines the operations that
can be done on the data, the meaning of the data, and the way values of that
type can be stored.
A data type, in programming, is a classification that specifies which type of
value a variable has and what type of mathematical, relational or logical
operations can be applied to it without causing an error. A string, for example, is
a data type that is used to classify text and an integer is a data type used to
classify whole numbers.
1. A Teacher would like to create a program that will classify if a student’s grade
must be marked Passed or Failed. Any grades lower than 60 is considered failed.
From this given information, please provide the necessary data type.
Answer: Data Type
Float
The float data type is the best data type for this variable since a student’s grade is
usually a real number (numbers with decimal places).
. Data Type
Float
3. Identify the data type that will read the two sides of a rectangle and calculate its
area.
Data Type
Integer
4.Identify what data type that will calculate the roots of a quadratic equation
ax2+bx+c=0. Hint: d=sqrt(b2-4ac), and the roots are: x1=(-b+d)/2a and x2=(-b-d)/2a
Data Type
Void
5.Identify what data type that will determine the largest value and prints the largest
value with an identifying message.
Data Type
Integer or Float
5. Print 1 to 20.
7. “I love Philippines”
9. 11/12/2019
10. 'C'
As its name indicates, a
data type represents a
type of the data which
you can process using
your computer program.
It can be numeric,
alphanumeric, decimal,
etc.
a. letterA = 'A'
b. True or False
c. a = 100000
d. 1.234
e. Hello World
LESSON 4 - Let’s do the checking
Answer Key
1. D
2. C
3. A
4. B
5. E
Acknowledgements
Writer: Gibson J. Olazo- MTII
Editors: Ariel Tosio-EPS, Vladimir B. Paraiso-Assistant Principal
Reviewers: Robert P. Velasquez – Principal, Perlito Malaya HT-VI,
Anthony Ducta HT-III
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