Computer Science 1: CPS109 With Prof. Kosta Derpanis

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 82

CPS109

COMPUTER SCIENCE 1
with Prof. Kosta Derpanis

Hello, World!
Part 1
, B i g Java : L ate O bj ec t s
H o rs t m a nn
LECTURE TOPICS
LECTURE TOPICS
Computers and programming
LECTURE TOPICS
Computers and programming
Introduction to Java
Computer components
computer
system
input
input
input

output
input

output
C input
P ALU control unit
U

registers
output
C input
P ALU control unit
U

registers
output
C input
P ALU control unit
U

registers
output

main memory
C input
P ALU control unit
U

registers
output

main memory
C input
P ALU control unit
U

registers
output

main memory
C input
P ALU control unit
U

registers
output

main memory

secondary storage
C input
P ALU control unit
U

registers
output

main memory

secondary storage

network
ENIAC
First electronic general-purpose computer
e r farm (c i rc a 19 95)
Pixar rend
C input
P ALU control unit
U

registers
output

main memory

secondary storage

network
Solving
Problems

Define
Problem
Solving
Problems

Define Analyze
Problem Problem
Solving
Problems

Define Analyze Design


Problem Problem Solution
Solving
Problems

Define Analyze Design Implement


Problem Problem Solution Solution
Solving
Problems

Update

alyze Design Implement


blem Solution Solution
Test
Solving
Problems

Update

alyze Design Implement


blem Solution Solution
Test
Solving
Problems

Update

alyze Design Implement


blem Solution Solution
Test
algorithm
a series of instructions to solve a problem
Algorithm
Characte
ristics
Algorithm
Characte
ristics

Order of steps must be correct


Algorithm
Characte
ristics

Order of steps must be correct


Operations must be unambiguous
Algorithm
Characte
ristics

Order of steps must be correct


Operations must be unambiguous
Operations must be feasible
Algorithm
Characte
ristics

Order of steps must be correct


Operations must be unambiguous
Operations must be feasible
Must produce a result
Algorithm
Characte
ristics

Order of steps must be correct


Operations must be unambiguous
Operations must be feasible
Must produce a result
Must stop in a finite amount of time
Bread
Ingredients:
3/4 cup warm water
1 package active dry yeast
1 tsp salt
1-1/2 tbsp sugar
1 tbsp vegetable shortening
1/2 cup milk
3 cups all-purpose flour

Directions:
1. Add dry ingredients.
2. Mix.
3. Add water.
4. Knead.
5. Let rise.
6. Bake.
Bread output
Ingredients:
3/4 cup warm water
1 package active dry yeast
1 tsp salt
1-1/2 tbsp sugar
1 tbsp vegetable shortening
1/2 cup milk
3 cups all-purpose flour

Directions:
1. Add dry ingredients.
2. Mix.
3. Add water.
4. Knead.
5. Let rise.
6. Bake.
Bread output
Ingredients:
3/4 cup warm water
1 package active dry yeast
1 tsp salt
1-1/2 tbsp sugar input
1 tbsp vegetable shortening
1/2 cup milk
3 cups all-purpose flour

Directions:
1. Add dry ingredients.
2. Mix.
3. Add water.
4. Knead.
5. Let rise.
6. Bake.
Sort the following numbers in ascending order:

6 1 13 7 11 9 2 8
Sort the following numbers in ascending order:

6 1 13 7 11 9 2 8

H ow wo u l d you so r t th is l i s t?
Ins
e rtio
ns
ort
program
a series of instructions that a computer
can interpret and execute
Program
ming
Language
s

Generation 1: Machine language (pure binary)


Program
ming
Language
s

Generation 1: Machine language (pure binary)

1110 0010
0110 0000
0001 0000
Program
ming
Language
s

Generation 1: Machine language (pure binary)

1110 0010
0110 0000
0001 0000
Te d i o u s to p ro gra m
Program
ming
Language
s

Generation 2: Assembly language


Program
ming
Language
s

Generation 2: Assembly language

Move the 4 bytes in memory at the address


contained in EBX into EAX:

MOV EAX, [EBX]


Program
ming
Language
s

Generation 2: Assembly language

Move the 4 bytes in memory at the address


contained in EBX into EAX:

MOV EAX, [EBX]


te r arch ite c t u re
Tied to compu
Program
ming
Language
s

Generation 3: High-level languages, e.g., Java


Program
ming
Language
s

Generation 3: High-level languages, e.g., Java

public class SimpleCounter


{
/* A simple counter from 1 to 100 */
public static void main(String[] args)
{
for(int count = 1; count <= 100; count++)
{
System.out.println(count);
}
}
}
Created by Sun Microsystems in 1991
“Write once, run anywhere”
Java is an object-oriented programming (OOP)
language
Java is an object-oriented programming (OOP)
language
Java is an object-oriented programming (OOP)
language

object 2

object 1 object 3
Java is an object-oriented programming (OOP)
language

object 2

object 1 object 3

inte rac t v i a
methods
Java is an object-oriented programming (OOP)
language

object 2

s a m e k i n d
e c t s o f th e s
obj p e o r c l a s
e sa m e t y
have t h
object 1 object 3
applet
vs.
application program
run from web browser

applet
vs.
application program
L 5
TM
H
L 5
TM
H
run from web browser

applet
vs.
application program
run from web browser

applet
vs.
application program
n g i nte r f a ce or con s o le
run from w i n d ow i
IDE
Integrated Development Environment
BlueJ

You might also like