Program
Logic
Formulation
What is PLF
Program Logic Formulation
The Program Logic Formulation are instructions in a program set in
a proper order to solve a problem. Provide a set of requirements to
five programmers, and each may build different program logic.
Logic
A system or set of principles underlying the arrangements of
elements in a computer or electronic device so as to perform a
specified task.
Mathematical Logic
Logic means reasoning. The reasoning may be a legal opinion or
mathematical confirmation. We apply certain logic in
Mathematics. Basic Mathematical logics are a negation,
conjunction, and disjunction. The symbolic form of mathematical
logic is, ‘~’ for negation ‘^’ for conjunction and ‘ v ‘ for disjunction.
System
A set of things working together as parts of a mechanism or an
interconnecting network; a complex whole.
Process of PLF
Process
• Program Design
• Development
• Implementation
• Documentation
• Review
Process
• Program Design
• Development
• Implementation
• Documentation
• Review
Program Design
FLOWCHARTS
What is Flowchart?
A flowchart is a type of diagram that represents a workflow or process. A
flowchart can also be defined as a diagrammatic representation of an
algorithm, a step-by-step approach to solving a task.
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.
Examples
FLOWCHART
Example 1
Sarah Cruz has been working for
COMPUTER Z Company for four
years. Last year, Sarah received a
5% raise, which brought her current
monthly pay to 25,000.00 pesos.
Sarah is scheduled to receive a 4%
raise next month. She wants to
write a program that will display, on
the computer screen, the amount
of her new monthly pay.
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Program Design
PSUEDOCODE
What is Pseudocode
Pseudocode is a plain language description of the steps in an algorithm or another
system. Pseudocode often uses structural conventions of a normal programming
language, but is intended for human reading rather than machine reading. It typically
omits details that are essential for machine understanding of the algorithm, such as
variable declarations and language-specific code.
The purpose of using pseudocode is that it is easier for people to understand than
conventional programming language code, and that it is an efficient and environment-
independent description of the key principles of an algorithm. It is commonly used in
textbooks and scientific publications to document algorithms and in planning of software
and other algorithms.
Examples
PSUEDOCODES
Example 1
Sarah Cruz has been working for
COMPUTER Z Company for four
years. Last year, Sarah received a
5% raise, which brought her current
monthly pay to 25,000.00 pesos.
Sarah is scheduled to receive a 4%
raise next month. She wants to
write a program that will display, on
the computer screen, the amount
of her new monthly pay.
Begin
Int BaseNum, Percnt,Result, BasePrcnt;
Input BaseNum;
Input Percnt;
BasePrcnt = Percnt / 100;
Result = BaseNum * BasePrcnt;
Output “The New Salary is “ . Result;
End
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Start
int score1, score2, score3, score4, Average, SumAve;
Input score1;
Input score2;
Input score3;
Input score4;
SumAve = score1+score2+score3+score4;
Average = SumAve / 4;
If (Average >= 75) {
Output “The Average is “ . Average;
Output “ You are passed.”
}
Else {
Output “The Average is “ . Average;
Output “You are failed.”
}
End
Program Design
CONDITIONAL STATEMENTS
Conditional Statements
Conditionals are programming language commands for handling
decisions. Specifically, conditionals perform different computations or
actions depending on whether a programmer-defined boolean condition
evaluates to true or false.
Conditional Statements
IF (conditions) {
//code
} elseif (conditions) {
//code
} else {
//code
}
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Start
int score1, score2, score3, score4, Average, SumAve;
Input score1;
Input score2;
Input score3;
Input score4;
SumAve = score1+score2+score3+score4;
Average = SumAve / 4;
If (Average >= 75) {
Output “The Average is “ . Average;
Output “ You are passed.”
}
Else {
Output “The Average is “ . Average;
Output “You are failed.”
}
End
Example 2
A student took four quizzes in a
term and would like to compute
their average. He also would like
to know if the average has a
passing mark. Note that grade
lower than 75% is failed.
Start
int score1, score2, score3, score4, Average, SumAve;
Input score1;
Input score2;
Input score3;
Input score4;
SumAve = score1+score2+score3+score4;
Average = SumAve / 4;
If (Average >= 75) {
Output “The Average is “ . Average;
Output “ You are passed.”
}
Else {
Output “The Average is “ . Average;
Output “You are failed.”
}
End
Program Design
LOOPINGS
What is Looping
Looping statement are the statements execute one or more statement
repeatedly several number of times. In Java programming language there
are three types of loops; while, for and do-while.
For loop
For loop is a control flow statement for specifying iteration, which
allows code to be executed repeatedly.
While loop
The while loop is used to repeat a section of code an unknown number of
times until a specific condition is met. For example, say we want to know
how many times a given number can be divided by 2 before it is less than
or equal to 1.
Do while loop
A do while loop is a control flow statement that executes a block of
code at least once, and then either repeatedly executes the block, or
stops executing it, depending on a given boolean condition at the
end of the block.
Program Design
OPERATORS
What is operators
operators are constructs defined within programming languages which behave
generally like functions, but which differ syntactically or semantically. Common
simple examples include arithmetic (e.g. addition with +), comparison (e.g.
"greater than" with >), and logical operations (e.g. AND, also written && in some
languages). More involved examples include assignment (usually = or:=), field
access in a record or object (usually.), and the scope resolution operator (often::
or.). Languages usually define a set of built-in operators, and in some cases
allow users to add new meanings to existing operators or even define completely
new operators.
542996051-Program-Logic-Formulation.pptx

542996051-Program-Logic-Formulation.pptx

  • 1.
  • 2.
  • 3.
    Program Logic Formulation TheProgram Logic Formulation are instructions in a program set in a proper order to solve a problem. Provide a set of requirements to five programmers, and each may build different program logic.
  • 4.
    Logic A system orset of principles underlying the arrangements of elements in a computer or electronic device so as to perform a specified task.
  • 5.
    Mathematical Logic Logic meansreasoning. The reasoning may be a legal opinion or mathematical confirmation. We apply certain logic in Mathematics. Basic Mathematical logics are a negation, conjunction, and disjunction. The symbolic form of mathematical logic is, ‘~’ for negation ‘^’ for conjunction and ‘ v ‘ for disjunction.
  • 6.
    System A set ofthings working together as parts of a mechanism or an interconnecting network; a complex whole.
  • 7.
  • 8.
    Process • Program Design •Development • Implementation • Documentation • Review
  • 9.
    Process • Program Design •Development • Implementation • Documentation • Review
  • 10.
  • 11.
    What is Flowchart? Aflowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task. 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.
  • 13.
  • 14.
    Example 1 Sarah Cruzhas been working for COMPUTER Z Company for four years. Last year, Sarah received a 5% raise, which brought her current monthly pay to 25,000.00 pesos. Sarah is scheduled to receive a 4% raise next month. She wants to write a program that will display, on the computer screen, the amount of her new monthly pay.
  • 15.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed.
  • 16.
  • 17.
    What is Pseudocode Pseudocodeis a plain language description of the steps in an algorithm or another system. Pseudocode often uses structural conventions of a normal programming language, but is intended for human reading rather than machine reading. It typically omits details that are essential for machine understanding of the algorithm, such as variable declarations and language-specific code. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment- independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications to document algorithms and in planning of software and other algorithms.
  • 18.
  • 19.
    Example 1 Sarah Cruzhas been working for COMPUTER Z Company for four years. Last year, Sarah received a 5% raise, which brought her current monthly pay to 25,000.00 pesos. Sarah is scheduled to receive a 4% raise next month. She wants to write a program that will display, on the computer screen, the amount of her new monthly pay. Begin Int BaseNum, Percnt,Result, BasePrcnt; Input BaseNum; Input Percnt; BasePrcnt = Percnt / 100; Result = BaseNum * BasePrcnt; Output “The New Salary is “ . Result; End
  • 20.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed. Start int score1, score2, score3, score4, Average, SumAve; Input score1; Input score2; Input score3; Input score4; SumAve = score1+score2+score3+score4; Average = SumAve / 4; If (Average >= 75) { Output “The Average is “ . Average; Output “ You are passed.” } Else { Output “The Average is “ . Average; Output “You are failed.” } End
  • 21.
  • 22.
    Conditional Statements Conditionals areprogramming language commands for handling decisions. Specifically, conditionals perform different computations or actions depending on whether a programmer-defined boolean condition evaluates to true or false.
  • 23.
    Conditional Statements IF (conditions){ //code } elseif (conditions) { //code } else { //code }
  • 24.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed.
  • 25.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed.
  • 26.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed. Start int score1, score2, score3, score4, Average, SumAve; Input score1; Input score2; Input score3; Input score4; SumAve = score1+score2+score3+score4; Average = SumAve / 4; If (Average >= 75) { Output “The Average is “ . Average; Output “ You are passed.” } Else { Output “The Average is “ . Average; Output “You are failed.” } End
  • 27.
    Example 2 A studenttook four quizzes in a term and would like to compute their average. He also would like to know if the average has a passing mark. Note that grade lower than 75% is failed. Start int score1, score2, score3, score4, Average, SumAve; Input score1; Input score2; Input score3; Input score4; SumAve = score1+score2+score3+score4; Average = SumAve / 4; If (Average >= 75) { Output “The Average is “ . Average; Output “ You are passed.” } Else { Output “The Average is “ . Average; Output “You are failed.” } End
  • 28.
  • 29.
    What is Looping Loopingstatement are the statements execute one or more statement repeatedly several number of times. In Java programming language there are three types of loops; while, for and do-while.
  • 30.
    For loop For loopis a control flow statement for specifying iteration, which allows code to be executed repeatedly.
  • 33.
    While loop The whileloop is used to repeat a section of code an unknown number of times until a specific condition is met. For example, say we want to know how many times a given number can be divided by 2 before it is less than or equal to 1.
  • 36.
    Do while loop Ado while loop is a control flow statement that executes a block of code at least once, and then either repeatedly executes the block, or stops executing it, depending on a given boolean condition at the end of the block.
  • 39.
  • 40.
    What is operators operatorsare constructs defined within programming languages which behave generally like functions, but which differ syntactically or semantically. Common simple examples include arithmetic (e.g. addition with +), comparison (e.g. "greater than" with >), and logical operations (e.g. AND, also written && in some languages). More involved examples include assignment (usually = or:=), field access in a record or object (usually.), and the scope resolution operator (often:: or.). Languages usually define a set of built-in operators, and in some cases allow users to add new meanings to existing operators or even define completely new operators.