CC 102 - Fundamental Programming Lecture 2
CC 102 - Fundamental Programming Lecture 2
Concepts
Example :[[
Example :[[
Begin
End
A
Read/input number
(n)
End
true
n<0
Display “ number is
false negative”
A
Basic Programming Concept
A
Example : Draw a flowchart the input 5 numbers , compute the total of
the 5 numbers , determine and display if the total is an “even
number” or an “odd number”. Hint : total = total + input
number(loop)
class HiThere
✓ a reserved {
word , public static void main (String[]args)
means you {
cannot use System.out.println("Hello World!");
}
this word as
}
an identifier
✓ Java is a
case
sensitive
class HiThere
✓ This is an
{
identifier, we
public static void main (String[]args)
can make up to
{
identify a
System.out.println("Hello World!");
component of
}
the program
}
✓ Identifiers
must be single
word consist of
AlphaNumeric.
Style /*
Line breaks and indents are A Simple Java Program
ignored by the compiler, but help */
greatly with readability. class HiThere
Comments {
▪ Comments are ignored by the public static void main (String[]args)
compiler. // This is the main method
▪ Comments may be delimited {
by /* */ System.out.println("Hello World!");
▪ Comments may be delimited }
by // to the end of the line. }