Computer Programming 1
Computer Programming 1
AUTHOR:
Hello! Please do not
reproduce my notes,
thank you! Goodluck,
future IT!
TYPES OF PROGRAMMING
PROGRAMMING CYCLE
IDENTIFIERS
SOURCE CODE – programming statements written in Words that have special predefined meaning in
a high-level language. Java language.
APPLET – program embedded in a webpage. JAVA DEVELOPMENT KIT (JDK) – includes a complete
set of JRE tools for developing, debugging, and
SIMPLE JAVA PROGRAM
monitoring Java Applications.
public class FirstJavaProgram { JAVA RUNTIME ENVIRONMENT (JRE) – contains
public static void main(String[] args) { everything required to run Java Applications on a
system.
System.out.println(“hello world”);
SYNTAX ERRORS – invalid statements that the Java
} compiler might encounter.
} LOGICAL ERRORS – the program produces wrong
result even if the syntax is correct.
MAIN METHOD – In Java, execution always begins
with the main method.
COMPUTER PROGRAMMING 1
AUTHOR:
Hello! Please do not
reproduce my notes,
thank you! Goodluck,
future IT!
EXAMPLE:
EXPRESSIONS
LOGICAL OPERATORS - return a boolean value based ARTITHMETIC EXPRESSIONS - an expression that
on the boolean result of the given expressions. It is returns a numeric value.
always evaluated from left to right.
INTEGRAL EXPRESSSION - if all operands in an
expression are integers and the expression returns an
integer type value.
EXAMPLE:
MIXED EXPRESSIONS
LOGICAL EXPRESSIONS
INPUT
EXAMPLE:
EXAMPLE:
EXAMPLE:
EXAMPLE:
SELECTION STRUCTURE
CONTROL STRUCTURE – is a statement that is used to MULTIPLE SELECTIONS (NESTED IF) – when one (1)
control the flow of a program. There are two (2) control statement, either selection or repetition, is
control structures: located within another, it is said to be nested. The if
- In a SELECTION STRUCTURE, the program statement can be nested inside another if statement
executes particular statements depending or an if…else statement nested within the if
on the given condition. This alters the flow of statement. A nested if statement allows a program
program execution by making a selection or to perform multiple selections.
choice. EXAMPLE:
- In a REPETITION STRUCTURE, the program
repeats particular statements a certain
number of times, depending on the given
condition. This alters the flow of program
execution by the repetition of one (1) or
more statements.
COMPUTER PROGRAMMING 1
AUTHOR:
Hello! Please do not
reproduce my notes,
thank you! Goodluck,
future IT!
EXAMPLES:
control variable until the loop condition CONTINUE STATEMENT – causes the loop to skip the
evaluates to false. remainder of its body and immediately reevaluate
its condition, and proceeds with the next iteration of
FOR LOOP – executes a sequence of statements
the loop.
multiple times and abbreviates the code that
manages the loop variable. - In a for loop, the continue statement causes
the control of the loop to immediately jump
to the update statement, and then the loop
condition is evaluated.
- The initialization indicates the starting value - In a while or do…while loop, using the
for the loop control variable, the condition is continue statement makes the control of the
the loop condition that controls the loop loop immediately jumps to the loop
entry, and the update is the expression that condition.
alters the loop control variable.
EXAMPLE:
EXAMPLE:
EXAMPLE:
EXAMPLE:
STRINGS
COMPUTER PROGRAMMING 1
AUTHOR:
Hello! Please do not
reproduce my notes,
thank you! Goodluck,
future IT!
CREATING STRINGS
ARRAYS
EXAMPLE:
MULTIDIMENTIONAL ARRAY - arrays where the
elements are arrays themselves.
EXAMPLE:
PRE-DEFINED FUNCTIONS
USER-DEFINED FUNCTIONS
TWO CATEGORIES:
PARAMETER PASSING
COMPUTER PROGRAMMING 1
AUTHOR:
Hello! Please do not
reproduce my notes,
thank you! Goodluck,
future IT!
RECURSIVE DEFINITION