You are on page 1of 32

TUNASAN NATIONAL HIGH SCHOOL

SDO - Muntinlupa City

Lesson 1 - Java Programming

ROWELL L. MARQUINA
Senior High School Teacher
TUNASAN NATIONAL HIGH SCHOOL
WHAT IS AN ALGORITHM?
An algorithm refers to a series of
well-defined instructions on how to
accomplish a task or solve a specific
problem.
▪ Giving directions on how to get to
somebody’s house is an algorithm.
▪ Following a recipe for baking a cake is
an algorithm.
▪ The steps to compute the for average
is also an algorithm.
IMAGE SOURCE:
https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
STEPS IN CREATING AN ALGORITHM
In creating an algorithm, it is very
important to determine the exact goal
or expected product first.
The goal or expected product of the
algorithm is called OUTPUT.

IMAGE SOURCE:
https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
STEPS IN CREATING AN ALGORITHM
After determining the output, the next
step is to identify the necessary
materials or elements needed to
accomplish the task.
The necessary materials or elements
for the program is called INPUT.

IMAGE SOURCE:
https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
STEPS IN CREATING AN ALGORITHM
If the input and output are already
identified, it is time to list the steps
needed to accomplish the task.
The steps needed to accomplish the
task is referred to as the PROCESS.

IMAGE SOURCE:
https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
CHARACTERISTICS OF AN ALGORITHM
▪ It should have well-defined input and output.
▪ The steps should be stated clearly and
unambiguously.
▪ It should have an exact start and end.
▪ It should be simple but precise.
▪ It should be practical.

IMAGE SOURCE:
https://imgbin.com/png/uxvDNRys/computer-programming-computer-icons-technology-algorithm-png
https://www.flaticon.com/free-icon/coding_1085774
WHAT IS A FLOWCHART?
A flowchart is a diagram that
illustrates a process, system
or computer algorithm.
Flowcharts are widely used in
multiple fields to document,
study, plan, improve and
communicate often complex
processes in clear, easy-to-
understand diagrams.

IMAGE SOURCE:
https://www.frevvo.com/blog/wp-content/uploads/2021/10/image5-2.png
FLOWCHART SYMBOLS
The American National
Standards Institute (ANSI) set
standards for flowcharts and
their symbols in the 1960s.
In 1970 the International
Organization for
Standardization (ISO)
adopted the ANSI symbols as
the international standard for
developing flowcharts.

IMAGE SOURCE:
https://uploads-ssl.webflow.com/6184b461a39ff13bfb8c0556/61de99e8171cc6468145551d_flowchart-symbols-800.png
FLOWCHART SYMBOLS
NAME OF
SYMBOL FUNCTION
SYMBOL
Indicates the beginning and end of the
Terminal Symbol
flowchart.
Its shows the process’ direction or the
Flowline Symbol
next steps in the process.
It shows the process or operations to
Process Symbol
be carried out by the program
It shows the step that contains a
Decision Symbol
control mechanism or decision.
It indicates the process of getting data
Input/Output
from the user or displaying data on
Symbol
screen.
IMAGE SOURCE:
https://uploads-ssl.webflow.com/6184b461a39ff13bfb8c0556/61de99e8171cc6468145551d_flowchart-symbols-800.png
FLOWCHART PROBLEM 1:
DETERMINING USER’S AGE:
Create a flowchart for a program
that will require the user to input
their year of birth. Using the user’s
year of birth, the program will
compute for the user’s age and
display its result on the computer
screen.
FLOWCHART SAMPLE
START The program is initiated.

1: birthyear, age The variables birthyear and age are introduced to the program as integers.

display The program displays the instruction “Enter Year of Birth: ” on screen .
“Enter Year of Birth:”

input The program get an input from the user and store its value in the variable birthyear.
birthyear

age = 2023 - birthyear The program computes for the value of age using the formula age = 2023 - birthyear.

display The program displays the value of age on the screen.


age

END The program is terminated.


FLOWCHART PROBLEM 2:
CONVERSION FROM
KILOGRAM TO POUND:
Create a flowchart for a program
that will require the user to input
a value in kilogram (kg). The
program will convert the inputted
value into pounds (lbs.) and
display its results on the screen.
FLOWCHART SAMPLE
START The program is initiated.

1: kilo, pound The variables kilo and pound are introduced to the program.

display
“Enter Weight in The program displays the instruction “Enter Weight in Kilogram:” on screen.
Kilogram:”

input The program get an input from the user and store its value in the variable kilo.
kilo

pound = kilo * 2.2 The program computes for the value of pound using the formula pound = kilo*2.2.

display The program displays the value of pound on the screen.


pound

END The program is terminated.


FLOWCHART PROBLEM 3:
COMPUTING FOR AREA:
Create a flowchart for a program
that will require the user to input
the length and width of a
rectangle. The program will
compute for the area of the
rectangle using the inputted
length and with and display its
results on the screen.
FLOWCHART SAMPLE
START The program is initiated.

1: length, width, area The variables length, width, and area are introduced to the program as integers.

display
“Enter Length of the The program displays the instruction “Enter Length of Rectangle: ” on screen .
Rectangle:”

input The program get an input from the user and store its value in the variable length.
length

display
“Enter Width of the The program displays the instruction “Enter Width of Rectangle: ” on screen .
Rectangle:”

input
The program get an input from the user and store its value in the width.
width

A The program will continue on the next part.


FLOWCHART SAMPLE
A The program continues.

1:area = length * width The program computes for the value of area using the formula area = length*width.

display
The program displays the value of area on the screen.
area

END The program is terminated.


FLOWCHART PROBLEM 4:
PLAYING WITH NUMBERS:
Create a flowchart for a program
that will require the user to input
four numbers. Using the inputs, the
program will compute for:
▪ the sum of 1st and 2nd number,
▪ the product of the 3rd and 4th number
▪ the square of the 2nd number
FLOWCHART SAMPLE
START The program is initiated.

1:
a, b, c, d, sum, product, square The variables a, b, c, d, sum, product, and square are introduced to the program.

display
“Enter the First The program displays the instruction “Enter the First Number: ” on screen .
Number:”

input The program get an input from the user and store its value in the variable a.
a

display
“Enter the Second The program displays the instruction “Enter the Second Number: ” on screen .
Number:”

input
The program get an input from the user and store its value in the b.
b

A The program will continue on the next part.


FLOWCHART SAMPLE
A The program continues.

1: display
“Enter the Third
Number:”
The program displays the instruction “Enter the Third Number: ” on screen .

input The program get an input from the user and store its value in the variable c.
c

display
“Enter the Fourth The program displays the instruction “Enter the Fourth Number: ” on screen .
Number:”

input
The program get an input from the user and store its value in the d.
d

B The program will continue on the next part.


FLOWCHART SAMPLE
B The program continues.

1: sum = a + b The program computes for the value of sum using the formula sum = a + b.

product = c * d The program computes for the value of product using the formula product = c*d.

square = b * b The program computes for the value of square using the formula square = b*b.

display
The program displays the value of sum on the screen.
sum

display
The program displays the value of product on the screen.
product

display The program displays the value of square on the screen.


square

END The program is terminated.


FLOWCHART PROBLEM 5:
PLAYING WITH NUMBERS:
Create a flowchart for a program
that will require the user to input
four numbers. Using the inputs, the
program will compute for:
▪ the cube of the 1st number,
▪ the half of the 2nd number,
▪ the 20% of the 3rd number,
▪ The product of multiplying the 4th
number by 100
FLOWCHART SAMPLE
START The program is initiated.

1: a, b, c, d, cube, half,
twentypercent, times100
The variables a, b, c, d, cube, half, twentypercent, and times100 are
introduced to the program.

display
“Enter the First The program displays the instruction “Enter the First Number: ” on screen .
Number:”

input The program get an input from the user and store its value in the variable a.
a

display
“Enter the Second The program displays the instruction “Enter the Second Number: ” on screen .
Number:”

input
The program get an input from the user and store its value in the b.
b

A The program will continue on the next part.


FLOWCHART SAMPLE
A The program continues.

1: display
“Enter the Third
Number:”
The program displays the instruction “Enter the Third Number: ” on screen .

input The program get an input from the user and store its value in the variable c.
c

display
“Enter the Fourth The program displays the instruction “Enter the Fourth Number: ” on screen .
Number:”

input
The program get an input from the user and store its value in the d.
d

B The program will continue on the next part.


FLOWCHART SAMPLE
B The program continues.

1: cube = a*a*a The program computes for the value of cube using the formula cube = a*a*a.

half = b / 2 The program computes for the value of half using the formula half = b / 2.

The program computes for the value of twentypercent using the formula
twentypercent = c * 0.20
twentypercent = c*0.20.

times100 = d * 100 The program computes for the value of times100 using the formula times100 = d*100.

display
The program displays the value of cube on the screen.
cube

display
The program displays the value of half on the screen.
half

C The program will continue on the next part.


FLOWCHART SAMPLE
1: C The program continues.

display The program displays the value of twentypercent on the screen.


twentypercent

display
The program displays the value of times100 on the screen.
times100

END The program is terminated.


PRACTICE TEST 1:
DOLLAR TO PESO CONVERSION:
Create a flowchart for a program that
will require the user to input the
amount in US Dollars. Using the
inputted amount, the program will
convert it to its Philippine Peso value
and display the answer on the screen.
Note:
1 US Dollar = Php 56.78
PRACTICE TEST 2:
COMPUTING FOR AVERAGE
Create a flowchart for a program
that will require the user to input
their grades in Mathematics, English,
and Science. The program will
compute for the average of the three
grades and display its result on the
computer screen.
PRACTICE TEST 3:
PLAYING WITH NUMBERS:
Create a flowchart for a program that will
require the user to input four numbers. Using
the inputs, the program will perform the
following:
▪ display the 1st number,
▪ get the product of 1st and 3rd number,
▪ get the product of multiplying the 2nd
number by the sum of the 3rd and 4th
number,
▪ the average of the four numbers increased
by 5.
ALGORITHM AND FLOWCHARTING

MR. ROWELL L. MARQUINA


Tunasan National High School
Senior High School Department

Email Address:
rowell.marquina001@deped.gov.ph
sirrowellmarquina@gmail.com
rmarquina@mitis.edu.ph

You might also like