Programming Basics
Programming Basics
1. Machine languages
2. Assembly languages
3. High-level languages
Algorithm
Is a sequence of precise instructions that
leads to a solution. These instructions are
expressed in English and must be complete
and unambiguous.
Flowchart
A flowchart is a diagram that uses graphic
symbols to depict the nature and flow of the
steps in a process.
Basic Flowchart Symbols
……………. Start/ Stop
……………. Decision
……………. Connection
n Example:
rate RATE Rate
Java Operators
1. Arithmetic Operators: (+, -, *, /, %)
2. Unary Operators: (++, --)
3. Assignment Operators:
(=, +=, -=, *=, /=, %=)
4. Relational Operators:
(<, <=, >, >=, ==, !=)
5. Logical operators: (&&, ||, !)
Operator Precedence
Highest
Operators Description precedence
++, -- Increment, Decrement, Parentheses
! Not
*, /, % Multiplication, Division, Remainder (mod)
+, - Addition , Subtraction
<, <=, >, Less than, Less than or equal , Greater than,
>=, ==, != Greater than or equal , Equal , Not equal
&& And
|| Or
=, +=, -=, Assign, Add and assign, Sub and assign, Multiple
*=, /=, %= and assign, Division and assign ,Mod and assign Lowest
precedence
Java Comments
n Java comments refer to pieces of explanatory text that are not
part of the code executed and are ignored by the compiler.
n Comments are very important in programming languages
because they make programs understandable to anyone reading
the code.
n One-line comment:
Average = (x+ y)/ 2; // Calculate the average of two numbers
n Multiline comment:
/* Putting an asterisk at the beginning of each line of a
multiline comment allow people looking at the code to
determine with a quick look what a comment and what is a
code. */
Java Escape Characters
Escape Sequence Description
\t Create a tab.