Intro to Programming
& Algorithm Design
Overview
This presentation can be viewed on line in a file named:
Copyrighthttp://web.fscj.edu/Janson/COP1000/ch01.IntrotoProg.ppt
2014 by Janson Industries
1
Objectives
▀
Explain
♦
Steps to success in this class
♦
Basic computer concepts
♦
Basic programming concepts
♦
Computer hardware
2
Copyright 2014 by Janson Industries
PP Presentations
▀
▀
Can be viewed on line or
downloaded
For all presentations and class
files, go to:
▮
http://web.fscj.edu/Janson/COP1000
3
Copyright 2014 by Janson Industries
This presentation is ch01.IntrotoProg (scroll to bottom)
Click the file name …
Chapter 1
© copyright Janson Industries 2014
4
… select Open (to view) or Save as (to download)
Chapter 1
© copyright Janson Industries 2014
5
If "Save as" selected, specify where to save to
Chapter 1
© copyright Janson Industries 2014
6
Class Success
▀
Read text before coming to class
▀
In class take good notes
♦
▀
▀
Copyright 2014 by Janson Industries
Suggestion: print out PP and use
as basis for notes
Will need a thumb/flash drive
Organize your work. Pay
attention to file:
♦
Name
♦
Location
7
Class Format
▀
For each chapter there will be a
lecture with an associated PP
♦
▀
Will cover the same material as the
chapter but with alternative
examples
Then non-graded and graded
labs will be assigned
8
Copyright 2014 by Janson Industries
Class Format
▀
Labs can be found on the class
website in a folder called Labs
♦
▀
Most graded labs are in Word
documents that follow the
naming convention of
♦
▀
Then in a subfolder named C#,
where # is the chapter number
Chapter # Lab.COP1000.doc
Where # is the chapter number
9
Copyright 2014 by Janson Industries
Class Format
▀
▀
▀
▀
You must do the non-graded
assgs to get credit for the graded
assgs
NG assgs broken up into several
pieces
Turn in each NG assg piece one
at a time and I will send the
solution
Then tackle the next piece
10
Copyright 2014 by Janson Industries
11
Copyright 2014 by Janson Industries
Many of the labs have videos
If you want to view, download these also
12
Copyright 2014 by Janson Industries
Concepts
▀
Computer
♦
▀
▀
Hardware (h/w): the computer
machinery
Software (s/w): group of
instructions that enable the h/w
to work
♦
Copyright 2014 by Janson Industries
Electronic device that processes
data into information according to
specific instructions
Like a recipe
13
Concepts
▀
Information processing cycle
Input
Processing
Output
Storage
▀
Computer can store input and
output
14
Copyright 2014 by Janson Industries
Concepts
▀
Input comes in two forms:
♦
Data: raw facts
► Can
♦
be text, numbers, images, etc.
Instructions
► Click
on a button/icon, type a command
► Software
▀
Output is information
♦
Useful/meaningful knowledge
15
Copyright 2014 by Janson Industries
Concepts
▀
Input
Computer Hardware
Input Input
Device
Keyboard
Microphone
Scanner
Mouse
Processing Output
CPU
Storage
Device
Hard drive
Thumb drive
CD/DVD drive
Memory cards
Output Output
Device
Printer
Monitor
Speakers
16
Copyright 2014 by Janson Industries
Concepts - Storage
▀
▀
Computer can hold data/information
All data (pictures, music, video,
etc.) stored as a series of zeroes
and ones
♦
Different systems for storing different
types of data
► ASCII,
Unicode for character data
► Binary, packed decimal for numbers
17
Copyright 2014 by Janson Industries
Lots of Different Storage Types
▀
External vs. Internal Storage
♦
▀
Internal also called Main Memory or
RAM
Many differences between the two
♦
Speed, capacity, persistence
► Volatile
▀
vs. nonvolatile
Key difference is, that MM
managed by CPU
♦
External memory has a separate
device that manages the media
18
Copyright 2014 by Janson Industries
Concepts
▀
▀
External storage examples
♦
Hard disk
♦
Memory stick
♦
CD/DVD
Internal storage examples
♦
RAM
♦
ROM
♦
VRAM
19
Copyright 2014 by Janson Industries
Concepts - Storage
▀
▀
Secondary storage measured in
Gigabytes/Terabytes
Internal storage measured in
Megabytes/Gigabytes
♦
Of course this begs the question:
"What's a byte?"
♦
Gather round while I tell you the story
of Snow White and the seven
dwarves…
20
Copyright 2014 by Janson Industries
Concepts - Storage
▀
Numbers are different, this binary
number: 0 1 0 1 1 0 1 1
▀
Is the equivalent of 91 (in base 10)
▀
In binary, each digit is a power of 2
♦
♦
Just like in decimal (base 10) where
each digit is a power of 10
So in base 10, 254 represents:
►2
groups of 100 (10 to the second power)
► 5 groups of 10 (10 to the first power)
► 4 groups of 1 (10 to the zero power)
21
Copyright 2014 by Janson Industries
Concepts - Storage
▀
So 0 1 0 1 1 0 1 1 represents
♦
♦
♦
♦
♦
♦
♦
♦
▀
Copyright 2014 by Janson Industries
0 groups of 128 (2 to the 7th)
1 group of 64 (2 to the 6th)
0 groups of 32 (2 to the 5th)
1 group of 16 (2 to the 4th)
1 group of 8 (2 to the 3rd)
0 groups of 4 (2 to the 2nd)
1 group of 2 (2 to the 1st)
1 group of 1 (2 to the zero)
64 + 16 + 8 + 2 + 1 = 91
22
Concepts
▀
Software
♦
▀
Instructions that the computer
(CPU) executes to transform the
input into output
Two types of software
♦
Systems
► Enables
the computer to function/run
more efficiently
♦
Application
► Performs
Copyright 2014 by Janson Industries
functions the user wants
23
Concepts
▀
Systems Software
♦
Operating systems
► Windows,
♦
Utility programs
► Zip,
♦
Mac OS, Linux
RAR/MP3 converter
Programming language translators
► Assemblers,
Compilers, Interpreters
• More on these a little later
24
Copyright 2014 by Janson Industries
Concepts
▀
▀
Application s/w categories
♦
Efficiency
♦
Entertainment
♦
Education
An application (app) consists of
both s/w and data
♦
An app’s s/w is broken up into
pieces called programs
► An
app can be comprised of 100’s
even 1000’s of programs
Copyright 2014 by Janson Industries
25
Concepts

How programs, internal and
external storage work together
1
Input Run
Run
Program Device Program
Internal
memory
CPU
3
Aka
Copy of
Program RAM
2
Copy of
Program
Storage External
Device memory
26
Copyright 2014 by Janson Industries
How Programs Work
▀
Once program is in MM, CPU reads
and executes one instruction at time
// OilCalc.java
import java.io.*;
public class OilCalc {
public static void main(String[] args) throws IOException {
BufferedReader dataIn = new BufferedReader(new InputStreamReader
(System.in));
int amount = 0;
double cost = 0;
String amtString = "";
System.out.print("Amount of oil is? ");
amtString = dataIn.readLine();
amount = Integer.parseInt(amtString);
if (amount <= 100) {cost = amount * 2.25;}
else if (amount <= 250) { cost = 100 * 2.25 + (amount-100) * 2.10;}
else { cost = 100 * 2.25 + 150 * 2.10 + (amount-250) * 1.99;}
}
System.out.println("The cost of the oil is $" + cost);
}
Copyright 2014 by Janson Industries
27
Programming Concepts
▀
Machine Language
♦
▀
0's and 1's the computer can execute
Problems with Machine Language?
♦
Hard for humans to understand and
write
► Easy
to make mistakes, takes a long time
to type
▀
First improvement
♦
Assembly level languages
28
Copyright 2014 by Janson Industries
Programming Concepts
▀
Assembly level languages short
commands/acronyms rather than
zeroes and ones
♦
Mul 30 18 16 means multiply the
numbers in locations 30 and 18 and
store the result in location 16
♦
Mov 24 32 means move the number
in location 24 to location 32
♦
Out 14 means display the value in
location 14
29
Copyright 2014 by Janson Industries
Programming Concepts
▀
Assembly level language must be
converted into machine language
♦
A piece of s/w called an Assembler
converts Assembly level language into
machine language
► Like
▀
s/w that converts a rar to an mp3
Problem with Assembly level
languages
♦
Copyright 2014 by Janson Industries
Programmer has to manage internal
memory
30
Programming Concepts
▀
High Level Languages (HLL)
♦
♦
English like commands
Strict syntax
► Like
♦
▀
HLL must also be converted into
machine language
2 types of S/W to translate HLL to
machine language:
♦
♦
Copyright 2014 by Janson Industries
grammar in a spoken language
Compiler
Interpreter
31
Programming Concepts
Source Code
file
Machine
Language file
HLL source
code
Editor
HLL source
code
Programmer
Copyright 2014 by Janson Industries
CPU
Machine
language
Machine
language
Compiler
Translate command
Programmer
OS
Run command
User
32
Programming Concepts
Source Code
file
CPU
HLL source
code
Editor
HLL source
code
Programmer
Copyright 2014 by Janson Industries
Machine
language
Interpreter
Run command
Programmer
33
Programming Concepts
▀
Lots of different HLLs
▀
Each language has advs/disadvs
♦
C and VB great for PC based apps
♦
COBOL good for business apps
♦
Fortran good for scientific apps
♦
Java good for PC/Server/Mobile
apps
34
Copyright 2014 by Janson Industries
Programming Environment
▀
▀
When designing, use tools to
generate flow chart diagrams and
pseudo code
When programming use an IDE
(Integrated Development
Environment)
♦
At a minimum an IDE will have a
source code editor
►A
source code editor is to a program
what word processing software is to a
document
35
Copyright 2014 by Janson Industries
Notepad++ is an example of a simple source code editor
Let’s a programmer enter, change and save source code
36
Copyright 2014 by Janson Industries
IDE
▀
Source code editors in IDEs will
have many more capabilities
♦
Show syntax errors
♦
Format code for readability
♦
Code completion
► Finish
a statement
► Add necessary tokens (semicolons,
parenthesis, etc.)
37
Copyright 2014 by Janson Industries
IDE
▀
Will also have other tools/functions
♦
Compiler(s) – support for many
languages
♦
Debugger – s/w that
► Traces
statement execution
► Can temporarily halt program execution
and allow programmers to display
program data
♦
Test environment
► Programmer
can run program and see
results
38
Copyright 2014 by Janson Industries
Colors indicate static text, types of
statements, language keywords, etc.
Error indicators
Area to see
program results
Lots of IDEs: RAD(IBM), Visual Studio(Microsoft, doesn’t support
39
Java), NetBeans(Open source/Oracle), Eclipse(Open source/IBM)
Copyright 2014 by Janson Industries
A Visual Editor lets you click and drag GUI components.
It generates the code!
Copyright 2014 by Janson Industries
40
Alternative Resource
▀
▀
Code.org
Uses videos and games gets
across the basic programming
structures which will be covered
over the next months
♦
http://learn.code.org/hoc/1
41
Copyright 2014 by Janson Industries
You can skip the video and go
straight to the instructions
Once done with
instruction, close window
and try exercises
42
Copyright 2014 by Janson Industries
The first puzzle will start
43
Copyright 2014 by Janson Industries
When puzzle finished will
allow you to continue to the
next one or you can click to
skip ahead
There may be more
instructions, click
X's to close
44
Copyright 2014 by Janson Industries
Click Continue to go
to next puzzle
45
Copyright 2014 by Janson Industries
Click Continue to go
to next puzzle
46
Copyright 2014 by Janson Industries
If you can't figure it out, scroll
down and click the help links
47
Copyright 2014 by Janson Industries
Code.org
▀
▀
I strongly recommend that you go
through all twenty puzzles over
the next 3 weeks
They will greatly help you
understanding the concepts of
♦
Alogorithms
♦
Sequential processing
♦
Selection
♦
Iteration
48
Copyright 2014 by Janson Industries
How Class Works
▀
▀
There's an entire COP1000 set
of lessons at
http://learn.code.org/
49
Copyright 2014 by Janson Industries
Unplugged activites have the
theory – good to read first
Then tackle the puzzles
50
Copyright 2014 by Janson Industries
Points to Remember
▀
Four major computer operations:
♦
Input
♦
Processing
♦
Output
♦
Storage
51
Copyright 2014 by Janson Industries
Points to Remember
▀
Everything in the computer
stored as zeroes and ones
♦
▀
Pictures, numbers, sounds
Two types of software
♦
Systems
♦
Application
52
Copyright 2014 by Janson Industries
Points to Remember
▀
Programs are written in a
programming language
♦
▀
▀
Referred to as source code
Source code must be translated
into machine language
Machine language can be
executed, source code cannot be
executed
53
Copyright 2014 by Janson Industries
Points to Remember
▀
▀
Programmers have lots of s/w
tools to help design and code
programs
Bring your thumb/flash drives to
the next class
54
Copyright 2014 by Janson Industries
Descargar

Intro to the AS/400 - Florida State College at Jacksonville