CPCS202 01 Introduction S19
CPCS202 01 Introduction S19
CPCS202 01 Introduction S19
Introduction to
Programming and Java
Objectives
To review Program Design and Problem-Solving Techniques
To describe the relationship between Java and the World Wide Web (§1.5).
To understand the meaning of Java language specification, API, JDK, and IDE
(§1.6).
To write a simple Java program (§1.7).
To display output on the console (§1.7).
To explain the basic syntax of a Java program (§1.7).
To create, compile, and run Java programs (§1.8).
To use sound Java programming style and document programs properly (§1.9).
To explain the differences between syntax errors, runtime errors, and logic
errors (§1.10).
To develop Java programs using NetBeans (§1.11).
What is an algorithm?
– A step-by-step series of instructions in order to
perform a specific task.
– An algorithm must:
Be lucid (clear), precise and unambiguous
Give the correct solution in all cases, and eventually end
Algorithm:
• Input the length in feet (LFT)
• Calculate the length in cm (LCM) by
multiplying LFT with 30
• Print length in cm (LCM)
LCM LFT x 30
Print
LCM
STOP
Algorithm:
• Input the Length (L) and width (W) of a
rectangle
• Calculate the area (A) by multiplying L with W
• Print A
START
Input
L,W
A LxW
Print
A
STOP
Y is N
A>B
Print A Print B
Input
VALUE1,VALUE2
Y is
N
VALUE1>VALUE2
Print
“The largest value is”, MAX
STOP
1101101010011010
Ada Named for Ada Lovelace, who worked on mechanical general-purpose computers. The Ada
language was developed for the Department of Defense and is used mainly in defense projects.
BASIC Beginner’s All-purpose Symbolic Instruction Code. It was designed to be learned and used easily
by beginners.
C Developed at Bell Laboratories. C combines the power of an assembly language with the ease of
use and portability of a high-level language.
C++ C++ is an object-oriented language, based on C.
C# Pronounced “C Sharp.” It is a hybrid of Java and C++ and was developed by Microsoft.
COBOL COmmon Business Oriented Language. Used for business applications.
FORTRAN FORmula TRANslation. Popular for scientific and mathematical applications.
Java Developed by Sun Microsystems, now part of Oracle. It is widely used for developing platform-
independent Internet applications.
Pascal Named for Blaise Pascal, who pioneered calculating machines in the seventeenth century. It is a
simple, structured, general-purpose language primarily for teaching programming.
Python A simple general-purpose scripting language good for writing short programs.
Visual Visual Basic was developed by Microsoft and it enables the programmers to rapidly develop
Basic graphical user interfaces.
Java's Performance
Java Is Multithreaded
Java Is Dynamic
p
ubl
iccla
ssTes
t{
pu
bli
cstat
icvoi
dmain
(St
ring
[]a
rgs
){ C
la
ssb
loc
k
Sys
tem
.ou
t.p
rin
tln
("W
elc
ometoJ
ava
!")
;Me
tho
dblo
ck
}
}
" " Opening and closing Enclosing a string (i.e., sequence of characters).
quotation marks
; Semicolon Marks the end of a statement.
Spacing
– Use blank line to separate segments of the code.
N e
xt-lin
e p
ubl
iccla
ssTes
t
sty
le {
pu
bli
cstat
icvoi
dmain
(St
rin
g[]arg
s)
{
Sys
tem
.ou
t.p
rin
tln
("B
loc
kStyle
s")
;
}
}
E n
d-of-lin
e
sty
le
p
ubl
iccla
ssTes
t{
pu
bli
cstat
icvoi
dmain
(St
rin
g[]arg
s){
Sys
tem
.ou
t.p
rin
tln
("B
loc
kStyle
s")
;
}
}