Nothing Special   »   [go: up one dir, main page]

FLOWCHARTING

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 58

VARIABLES

A variable is a storage location that uses


a symbolic name associated with a value.

Presentation 20XX 1
title
RULES IN NAMING VARIABLES:

You can use a combination of letters,


numbers and underscores
The first character must be a letter
You cannot use keywords reserved by
Small Basic
Presentation 20XX 2
title
VARIABLE TYPES
INTEGER
it is a type of variable that used to represent
whole or non-decimal numbers. For example, 1,
20, 100. You cannot use a comma in large
numbers

Presentation 20XX 3
title
VARIABLE TYPES
STRING
it stores a list of various characters that can be
name, list of numbers, a sentence, a
paragraph, or any character.
Strings are always enclosed in quotes(“”), for
example: “Juan B. Cruz” and “25”

Presentation 20XX 4
title
VARIABLE TYPES
BOOLEAN

It is a type of variable that can have one of


two values: true or false.

Presentation 20XX 5
title
VARIABLES IN EXPRESSIONS

PEMDAS- Parenthesis,
Exponents, Multiplication, Division,
Addition, and Subtraction
When several operations take place within the same equation, some operations are executed before
others.
Operations are executed in the following order:

Presentation 20XX 6
title
a. Parentheses or
b. Exponents and roots
brackets
c. Multiplication and
division
d. Addition and subtraction

Presentation 20XX 7
title
S M A L L BASIC
Small Basic combines a friendly environment
with a very simple language and a rich and
S impl engaging set of libraries to make your
programs and games pop! In a matter of few
e lines of code, you will be well on your way
to
creating your very own game!
Share your programs with your

S ocia friends and let them import your


published programs and run them

l on their computer.
Learn programming concepts starting with the

Gradual fundamentals and move your way up. Small


Basic is based on .NET and what you learn
here could be easily applied to other .NET
programming languages like Visual Basic.
Learn programming concepts starting with the

Gradual fundamentals and move your way up. Small


Basic is based on .NET and what you learn
here could be easily applied to other .NET
programming languages like Visual Basic.
Why should we Learn to Code?
Activity 1: Display
Gender
Create a program that will type the Gender (Male/ Female).

1. Launch Microsoft Small Basic.


2. Print the program title as “Gender” in the TextWindow.

3. Continue the program by typing the following:


TextWindow.Write(“Type Gender:”)
gender= TextWindow.Read()
TextWindow. WriteLine(“You are , “
+gender)
4. Use the If Statement
 Conditions help you build programming
logic. The most commonly used condition
is the If Then, Else statement. The keywords
If, Then, and Endif are logical expressions
that will allow you to make decisions.
 The If..then keywords always end
up with Endif. The Elself keyword
provides an alternate condition.
Activity 2: Hands on. Creating If Condition
Activity 2: Hands on. Creating If Condition
If (Clock.Hour < 12)
Then
TextWindow.WriteLine("Goo Morning
d World")
EndIf
If (Clock.Hour >= 12) Then
Evenin
TextWindow.WriteLine("Good g
World")
EndIf
Activity 3: Hands-on: Even or Odd
Activity 3: Hands-on: Even or Odd
TextWindow.Write("Enter a number:
") num = TextWindow.ReadNumber()
remainder = Math.Remainder(num, 2)
If (remainder = 0) Then
TextWindow.WriteLine("The number
is Even")
Else
TextWindow.WriteLine("The number
is Odd")
EndIf
Activity 3: Hands-on: Even or Odd
TextWindow.Write("Enter a number:
") num = TextWindow.ReadNumber()
remainder = Math.Remainder(num, 2)
If (remainder = 0) Then
TextWindow.WriteLine("The number
is Even")
Else
TextWindow.WriteLine("The number
is Odd")
EndIf

 In this program, we’ve introduced another new useful operation, Math.Remainder. And yes, as
you already might have figured out, Math.Remainder will divide the first number by the
second number and then give back the remainder.
Create a code with adAdinsg snuimgbnerms . Wenritet:in a ½
sheet of paper.
Activity 3: Hands-on: Even or Odd
 Endless execution: using Goto statement
TextWindow.Write("Enter a number: ")
num = TextWindow.ReadNumber()
remainder = Math.Remainder(num, 2)
If (remainder = 0) Then
TextWindow.WriteLine("The number is Even")
Else
TextWindow.WriteLine("The number is Odd")
EndIf
Goto begin
Body Fat
In thisPercentage
Lesson, you should be able to:

1. identify the use of “If Then Endif ” conditions.


2. identify how to use endless execution using
GoTo statement: and
3. create a program that will compute for the
Body Fat Percentage (BFP).
Body Fat


Percentage
Is the percentage of fat that your body has.
For your body to function properly, your body should
have a percentage of essential body fat and storage
body fat.
 It is the only measurement that directly calculates a person’s
relative body composition without regard to height or
weight.
Body Fat
Percentage
Body Fat Percentage = (Total Bodyweight-Lea Bodyweight)x
100
(Your Body Weight)
Description Women Men
Essential Fat 10-13% 2-5%
Athletes 14-24% 6-13%
Fitness 21-24% 14-17%
Average 25-31% 18-24%
Obese 32%+ 25%
Body Fat
Percentage
To get your body fat percentage, use the
following formula:

For Men:

A. (total body weight x 1.082) + 94.42


B. Waist measurement x 4.15
C. Lean Body Mass: A-B
D. Body Fat Weight: Total Bodyweight – C
E. Body Fat Percentage = (D x 100)/ total body
Body Fat
To get your body fat percentage, use the
Percentage
following formula:
For Women:
A. (Total body weight x 0.723) + 8.987
B. Wrist measurement (at fullest point) / 3.140

C. Waist measurement (at navel) x 0.157


D. Hip measurement (at fullest point) x 0.249
E. Forearm measurement (at fullest point) x 0.434
F. Lean Body Mass: A + B – C – D + E
G. Body Fat Weight: Total Body weight – F
H. Body Fat Percentage = (G x 100) / total body weight
Getting the
Measurement
Choose a partner. In the table on the next page, record
your own measurements and their body measurements.
Activity 1: Creating a Body Fat
Calculator
Create a program that will ask the user to enter his or her
body measurements to compute for body fat percentage.

1. Launch Microsoft Small Basic.


2. Print the program title as “Body Fat Calculator” in the

TextWindow.
3. Continue the program by typing the following:
TextWindow.WriteLine(“Type if you are male or female:”)
gender= TextWindow.Read()
4.Use the If Statement to determine if the gender is male or
female. Remember, each has a different formula in getting the
body fat percentage.
 Conditions help you build programming logic.
The most commonly used condition is the If

Then Else statement. The keywords If,


Then,
and Endif are logical expressions that will
allow you to make decisions.
 The If..then keywords always end
up with Endif. The Elself keyword
Creating Simple If Conditions

Create a program that will ask the user to


enter his or her body measurements to
compute for body fat percentage.

1. Launch Microsoft Small Basic.

2. 2. Print the program title as “Body Fat


Calculator in the TextWindow.
Basic
Programming
Flowchart
What is
•A flowchart?
flowchart is a
visual representation of the
sequence
of steps and decisions
needed to perform a process.
Each step in the sequence is
noted within a diagram shape.
Steps are linked by
connecting lines and
directional arrows.

This allows anyone to view


the flowchart and logically
follow the process from
beginning to end.
Commonly used Flowchart
Start/E nd The terminator
symbol
the starting or marks
ending
Start/ point
the system.
of It
E nd usually
the word "Start"
contain
ors
"End."
Commonly used Flowchart
Action or Process A box can represent a single
step ("add two cups of
flour"), or an entire sub-
process ("make bread")
within a larger process.
Commonly used Flowchart
Document Symbol
A printed document
or report.
Commonly used Flowchart
Represents multiple
DDooccuMummueeltni
documents in the process.
nptltSeSyymmbbooll
Documents Symbol
Commonly used Flowchart
Decisio
A decision or branching
n point. Lines representing
Symbol different decisions emerge
from different points of the
diamond.
Commonly used Flowchart
Input and Represents material or
Output
Symbol information entering or
leaving the system, such as
customer order (input) or a
product (output).
Commonly used Flowchart
Manual Represents a step where a
Input user is prompted to enter
Symbol
information manually.
Commonly used Flowchart
Preparatio Represents a set-up to
n another step in the process.
Symbol
Commonly used Flowchart
Indicates that the flow
Connecto continues where a matching
r symbol (containing the
Symbol
same letter) has been
placed.
DIFFERENT TYPES
OF FLOWCHARTING
Star
t
SEQUENCE
No Branching

End
Start

SELECTION
Conditions

Branching Forwards

End
Start
Pretes

REPETITION t
Loop

Two Different Looping Styles F


(Branching Backwards) Conditions

T End
Start
Pretes

REPETITION t
Loop

Two Different Looping Styles


(Branching Backwards)
T
Conditions

F
End
Examples of
Flowchartin
g
EXAMPLE OF
FLOWCHARTING
EXAMPLE OF
FLOWCHARTING
EXAMPLE OF
FLOWCHARTIN
G
EXAMPLE OF
FLOWCHARTING
Examples of
Flowchartin
g
ACTIVITY

• Fill in the flowchart with


the correct sequence of
steps based on the given
algorithm.
Create a flowchart with the correct sequence
of steps based on the algorithm below.

• Step 1: Input Grades of 4 subject S1, S2, S3 and S4.


• Step 2: Calculate the average grade with the formula “
Grade = ( S1+ S2+ S3 +S4) / 4
• Step 3. If the average grade is less than 60, print
“Fail”, else print “Pass”.
Star
t

S1, S2, S3,


S4

S1+S2+S3+S4

If Ave >
60

Fai Pas
l s

End

You might also like