Sie sind auf Seite 1von 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 1 Module 1


Learning Competency:

APPLYING PROGRAMMING SKILLS IN A SECOND LANGUAGE


TLE_ICTCP9-12PS-IIa-b-2
LESSON 1 - LO 2. CODE USING STANDARD ALGORITHMS:
Algorithms

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:
GIBSON J. OLAZO
Master Teacher II

1
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.

1
TLE_ICTCP9-12PS-IIa-b-2

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


1. understand standard algorithm; and
2. code using standard algorithms.

Algorithm – the step-by-step procedure of solving a problem.

End point - the final stage of a period or process.

Outcome - the way a thing turns out; a consequence.

Starting point - a place or position where something begins; a place or position


where something begins.

2
What have you learned from your Grade 11 lessons in Computer Programming?
What lesson/s you love the most? and you love the least?

3
Multiple Choice: Choose the letter of the correct answer that referred to the
statements below on the steps in writing an algorithm.
1. To determine the outcome of your code, one must know?
A. What is the specific problem you want to solve or the task you want it to
accomplish?
B. What facts will we learn from the process?
C. What formulas are applicable to the issue at hand?
D. What will be added or no longer exist?

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.

4
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.

5
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.

STEPS IN WRITING AN ALGORITHM IN PROGRAMMING


1. Determine the outcome of your code. What is the specific problem you want
to solve or the task you want it to accomplish?
2. Decide on a starting point. Finding your starting and ending point are crucial
to listing the steps of the process. To determine a starting point, determine the
answers to these questions:
• What data/inputs are available?
• Where is that data located?
• What formulas are applicable to the issue at hand?
• What are the rules to working with the available data?
• How do the data values relate to each other?
3. Find the ending point of the algorithm. As with the starting point, you can
find the end point of your algorithm by focusing on these questions:
• What facts will we learn from the process?
• What changes from the start to the end?
• What will be added or no longer exist?
4. List the steps from start to finish. Start with broad steps. 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.
5. Determine how you will accomplish each step. Now that you have a step-
by-step outline, it's time to think about how you might code each step.
6. Review the algorithm. Now that you've written your algorithm, it's time to
evaluate the process. Your algorithm is designed to accomplish something
specific, and you'll need it to start writing your program.

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.

6
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

EXAMPLE 1: Write an algorithm to convert the length in feet to centimeter

.
Algorithm

Step 1: Input Lft


Step 2: Lcm=Lft x 30
Step 3: Print Lcm

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

7
1. Write an algorithm to print 1 to 20.

2. Write an algorithm to Convert temperature: Fahrenheit to Celsius. C=5/9*(F-32)

3. Write an algorithm 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

4. Write an algorithm that reads two values, determine the largest value and prints
the largest value with an identifying message.

8
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.

Direction: Write your understanding about the following:

How can an algorithm help in making an efficient program?

9
Multiple Choice: Choose the letter of the correct answer that referred to the
statements below on the steps in writing an algorithm.
1. To determine the outcome of your code, one must know?
A. What is the specific problem you want to solve or the task you want it to
accomplish?
B. What facts will we learn from the process?
C. What formulas are applicable to the issue at hand?
D. What will be added or no longer exist?

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.

10
LESSON 1 - Let’s do the checking

Answer Key

1 Algorithm: 3 Step 1: Input a,b,c


Step 2: d=sqrt(bxb-4xaxc)
Step 1: Initialize X as 0, Step 3: x1=(-b+d)/(2xa)
Step 2: Increment X by 1,
Step 4: x2=(-b-d)/(2xa)
Step 3: Print X,
Step 4: If X is less than 20 then Step 5: Print x1,x2
go back to step 2.

2 Algorithm: 4 Step 1: Input VALUE1, VALUE2


Step 2: if (VALUE1>VALUE2) then
Step 1: Read temperature in MAX=VALUE1
Fahrenheit else
Step 2: Calculate temperature MAX=VALUE2
with formula C=5/9*(F-32) Step 3: Print “The largest value
Step 3: Print C is”,MAX

1. How can an algorithm help in making an efficient program?


Answer: An algorithm makes the whole procedure more efficient as well
consistent. It helps in identifying decision points, processes, and essential
variables to solve the problem. A programmer can also see the errors in a
particular process using an algorithm.

11
Innovative Training Works, Inc. “Computer Programming Volume I” Technical
Vocational Livelihood K to 12 First Edition
https://faradars.org/wp-content/uploads/2015/07/Algorithm-and-Flow-Chart.pdf
https://sielearning.tafensw.edu.au/toolboxes/Database_Administration/software/cont
ent/programmingconstructs/control_structures.htm
https://study.com/academy/lesson/what-is-an-algorithm-in-programming-definition-
examples-analysis.html

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

12
1

Das könnte Ihnen auch gefallen