word version

advertisement
CIS 150
Announcements
Lecture 01
Fall 1999
Add yourself to my email list & grade book by clicking Registration
Read Chapter 1
Lab 1 is Due 2nd lab period
Class grades currently inactive
Questions
Who should take this course??
People who want to learn how to program computers.
Majors, Mathematicians, Natural Science majors
Expected Background
CIS 125/CIS 123 or equivalent
Skills Can send/receive email
Can look at web pages
Has written a 10 line program
Chapter 1
Overview of Programming &Problem Solving
A program is a logical sequence of steps.
Computer allows for more efficiently , more quickly and
more accurately . It is NOT intelligent. It cannot think.
It only frees people from repetitive and boring tasks.
If you cannot explain how to do a task you will NOT be
able to program the computer to do the task.
How Do we write a Program?
3 phases
Phase 1 Problem Solving
1. Analysis and Specification – Understand the problem
and what the solution must do
2. General Solution (algorithm) Develop a logical
sequence of steps that solve the problem
3. Verify – follow the steps exactly to make sure that the
your algorithm solves the problem
Phase 2 Implementation
1. Concrete Solution – Translate your algorithm to a
programming language.
2. Test Run the program on sample data to make sure it
works.
Phase 3 Maintenance Phase
1. Use – Use the program
2. Maintain – Modify the program to meet the changing
requirements or to correct any errors that show up in
using it.
Any time the program is modified it is necessary to repeat
the problem solving and implementation phases. The
above is called the program’s life cycle.
Algorithm Example (How to start a car)
1. Insert Key
2. Put car in Park (or Neutral)
3. Depress Gas pedal
4. Turn key to start position
5. If the engine starts within six seconds, release the key
6. If the engine does not start within six seconds release the
key and repeat steps 3- 6 but not more than 5 times.
7. If the car does not start call the mechanic
Without the line (not more than 5 times) the program might
never terminate. This is called an infinite loop
Once one has an algorithm, one must translate it to a
programming langauge. We will C++ in this course.
What is a programming language?
English like
Has few words to learn (around 20-30)
Must be exact (a semi colon out of place or a misspelling
will make the program not run correctly)
The computer really only understands machine language
For example
Instruction name
Machine Language Form
Add
100101
Subtract
010010
A compiler translates programs written in high-level
language (C++, Pascal, FORTRAN, COBOL, Java, Ada)
into machine language.
The english like program you write is called the source
program.
The machine language translation is called the object
program.
One benefit of high-level language is portability (able to
move it from 1 type of computer to another) . Not as
“portable” as we would like. Most portable language is
Java.
So to write a program one must
1. write it down (using an editor)
2. translate it to machine language (using a compiler)
3. run it.
Modern compilers have an “Integrated Development
Environment” (IDE) to do all three and more. Turbo 5.02
is one such compiler. Visual C++, and CodeWarrior are 2
others.
What are the types of instructions that a computer can
understand?
1. transfer data from one place to another
2. input data from an input device (a keyboard or mouse)
and output data (screen or file)
3. Store data on a floppy or internally
4. Compare 2 data values
5. Do arithmetic
4 types of control
sequence
Statement1  Statement2  Statement3 …
Branching
If <condition> then <statement1> else <statement2>
Looping
While <condition> do Statement1
What is a computer??
There are 6 components
1. memory unit  ordered sequence of cells in which to
store information
central processing unit (CPU) has 2 components the
2. arithmetic logic unit and
3. control unit. Some CPUs are Pentium, G4,
4. input devices  keyboard, mouse,
5. output devices  screen printer
6. auxiliary storage  floppy, zip drive, hard drives
Different types of computers
Mainframe large  to be used by multiple users at once
Small size  personal computer pc
Other terms
interface  a link connecting 2 independent systems.
operating system manages the computers resources
programs, printers, modem,
editor  used to create and modify programs and data
Ethics
Programs are easy to copy . Most are copywritten Illegal
coping is called Software Piracy
Professionals have an ethical obligation to not engage in
piracy and to try to stop it.
Stealing Data is also piracy as is stealing computer time.
Software Engineering
The science of writing programs
Hints:
Ask Questions !!!!
Look for things that are familiar
Solve things by analogy
Divide and Conquer
Download