+ All Categories
Home > Documents > Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm –...

Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm –...

Date post: 23-Dec-2015
Category:
Upload: harriet-greene
View: 213 times
Download: 0 times
Share this document with a friend
Popular Tags:
103
Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard
Transcript
Page 1: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Introduction to Programming

• CST 112 Section 501 CRN:26108

• Grant-Caumsett Hall 203

• Monday 6:00 pm – 9:50 pm

Welcome Aboard

Page 2: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Introduction to Programming

Instructor:Cheo TengBrookhaven National LaboratoryPhoton Science Dept.

(accelerator control Group)631-344-5028 (BNL Phone #)[email protected]

Page 3: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

3

Text Book:Learning Processingby Daniel ShiffmanISBN:978-0-12-373602-4

How expensive is it?

Introduction to Programming

Page 4: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

4

Do we need to buy the text book?

It is recommended because we’ll do many excises in the book. Having the book will make your life much easier.

However, you can survive (barely?) without the book.

Introduction to Programming

Page 5: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

5

Supply: USB drives to save files and transfer

data.

Very cheap when they are on sale. About $0.50 to $1 per GB, or even

less.

Every one should have one or two.

Introduction to Programming

Page 6: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

6

Course Web Pages:

www2.sunysuffolk.edu/tengc/cst112

Outline Announcements Slides Projects Data files for projects and exercises Answers to some exercises Attendance and project status

Introduction to Computing

Page 7: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

7

Objective Introduction to computer concepts,

Windows XP, network security and protection.

Basic concepts and usage of Office 2010, Word, Excel, Access, and PowerPoint. In addition to the contents of the text book, some advanced topics will be introduced.

Introduction to Computing

Page 8: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

8

Attendance Policy

Attending classes is very important Firm but flexible policy If you can not attend a class,

• call 631-851-6754 (Caumsett Hall Rm 220) or • email [email protected]

Attendance Grades: 10% goes to the final grade.

Introduction to Programming

Page 9: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

9

Fail or Withdrawal One should go to registrar to formally

withdraw from the class if quitting attending the class after some date. For example, one quits the class after the midterm exam.

If you forget to formally withdraw, I usually assign W as your final grade if the College permits. However, if you need to get an F in order to get financial aid, please send me an email.

If the College does not allow professors to assign W, I will assign F for lack of choices.

Introduction to Programming

Page 10: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

10

Grading Policy

Specified in the outline In general, if one attends the classes,

finishes lab work, exams and projects, one gets a relatively good grade.

Do not worry about grades, to learn something is more important.

Introduction to Programming

Page 11: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

11

Topics The language we use is Java However, we use a language called

“processing” in the first several classes. Processing is based on java but on a

higher level. We’ll use processing to draw colored

balls (or other objects) and move them on the screen.

Introduction to Programming

Page 12: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

12

Topics

In the remaining classes we use Java!!! Our goal is to be able to write medium

size programs at the end of the class. I enjoy to answer questions from you

and discuss them with you. Please be actively involved in the class activities.

Introduction to Programming

Page 13: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Defining Computers

A computer is an electronic device accepts input processes and stores data produces output

Page 14: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Types of Computers

Personal computers• Desktop• Notebook (Laptop) • Tablet PC

Hand-helds: PDAs, MP3 players, Cell phones

Mainframes Supercomputers Other computers (at home, in car…)

Page 15: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Types of Computers Personal computers are used for general computing

tasks.

Hand-held computers fit in the palm of your hand and run on batteries.

Mainframes are used by companies to provide centralized storage, processing, and management for large amounts of data. Large high-speed computers, especially one supports many workstations and devices.

Supercomputers are the largest and fastest of computers, and can process an enormous volume of data. They are particularly powerful mainframe computers.

Page 16: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Types of Computers

Desktop: (HP, Dell, IBM…)• Usually more powerful and cheaper

than laptops• Needs separate monitor, not easy to

move around• Could be replaced by laptops and

tablets in the near future?

Page 17: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Types of Computers

Notebook, Netbook & iPad• Small & lightweight.• Portable• Netbook: browsing• Internet• Tablets (7” and 10”)

Page 18: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Types of Computers

Supercomputers are the largest and fastest computers. BNL Bluegene

Mainframe s are very powerful computers, but not as powerful as supercomputers.

Clusters: consists of hundreds and more processors.

Page 19: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Computer SystemsA computer system is made up of: Hardware — the physical components.

the mechanical, magnetic, electronic, and electrical devices comprising a computer system, as the CPU, disk drives, keyboard, or screen. Can be touched.

Software — the programs or lists of instructions to direct the operations of computers. Can not be touched.

Software could be more expensive than hardware. Why do most people KEEP using Windows system?

Page 20: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Can we reduce the weight of a computer by deleting its software (files).

No!!!

Software has no weight.

Page 21: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: major components

Motherboard CPU (Central Processing Unit) Memory Storage devices I/O (Input/Output) devices Network devices Power supply, case, video card,

sound card…

Page 22: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Motherboard

Also called mainboard

Located inside the computer case

Holds and connects all essential components

Page 23: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: CPU

CPU - micro processor• A silicon chip

designed to manipulate data

• The brain of a computer.

• 64-bit CPUs and 32-bit CPUs

Page 24: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: CPU (cont.) Intel, AMD, Apple, IBM… make

CPUs. Its speed is determined by:

• Clock speed (Hz)• Word size (32-bit and 64-bit)• Processor type• Usually, motherboard and CPU are

the most expensive components in a computer. High-end video cards are not cheap either.

Page 25: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Question

1. What are the two most expensive components in a computer?

Page 26: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Units of Memory and Storage Computer understands 0 and 1 only:

on/off state, N/S pole, 0/5 volts… 1 (“on”) and 0 (“off”) are referred to

as bits. A byte has 8-bits. Two bytes

represent a unique character (Unicode)

Decimal numbers and binary numbers.

Page 27: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Units of Memory and Storage Everything in the computer memory

and storage devices is a number! A computer understands only numbers.

Number number Character number (ASCII code) Grey level number ( usually 0 – 255) Color three numbers (R/G/B)

Page 28: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Question

2. A byte stores 256 different numbers, what are ASCII code values for English alphabets?

Page 29: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: units of Memory and Storage

Kilobyte (KB) = one thousand (1024) bytes

Megabyte (MB) = one million (1024 KB) bytes

Gigabyte (GB) = one billion bytes Terabyte (TB) = one trillion bytes

Page 30: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Memory

Computer memory is a set of storage locations.

Five types of memory:• Random access memory (RAM)• Cache memory, L1, L2, L3, fast &

expensive• Virtual memory, a form of caching• Read-only memory (ROM)• Complementary metal oxide semiconductor

memory (CMOS), battery-powered

Page 31: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Memory

RAM --- Random Access Memory• Sits on motherboard and closes to

CPU• Also called volatile memory,

primary memory, and main memory.

• Most important memory type.• 256 MB to many GBs.• Fast CPU + big memory + (fast

graphical card) a fast computer.

Page 32: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Memory Cache memory

• Special high-speed memory chip on the motherboard or CPU

• Stores frequently and recently accessed data and commands.

• Usually 1 to ??? MB.• The bigger, the better, also more

expensive.

Page 33: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Memory Virtual memory is extra memory that

simulates RAM if more is needed. Limited by the memory space (word size).

Read-only memory (ROM) is the permanent storage location for a set of instructions the computer uses.

CMOS memory is semi-permanent information about where essential software is stored. e.g. PC must know its disks types, available memory, video type, and other hardware settings at boot time. PC stores its essential information in the CMOS memory even when the PC is unplugged.

Page 34: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Storage Media

Magnetic storage devices • Hard disks—several magnetic oxide

covered metal platters usually sealed in a case inside the computer

• Tape—inexpensive, slow, archival storage for large companies who need to back up large quantities of data.

• Floppy disks: (almost) obsolete

Page 35: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Storage Media

Optical storage devices• CD-R - store 700 MB of data• CD-RW: not reliable• DVD—can store between 4.7 and 15.9

GB of data; Blue-ray discs and HD-DVD can store between 15 and 50 GB of data

Page 36: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Storage Media

Flash memory cards• Small, portable cards: rewritable• Used in digital cameras, handheld

computers, video game controllers, and other devices

• Most commonly-used: SD (SDHC) cards – Secure Digital.

Page 37: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Storage Media USB drive, USB

flash drive• from 32 MB to 16 GB

and more • Plug directly into the

USB port (hot operation)

• Rewritable• Best portable storage• Small and

inexpensive: $1.50/GB

Page 38: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Differences between memory & storage

Speed Persistent Size Location

Memory Fast No Limited On board

Storage Slow Yes Unlimited(?) External

Page 39: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Question

3. When we talk about memory and storage, how do you compare computers and people?

Page 40: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Input/Output Input:

• Data you type• Data by reading files• Data through Internet.• Data from sensors……• Other sources

Output: The result of computer processing.

Page 41: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Input/Output

Peripheral devices • Accomplish the input, output, and

storage functions.• Not on the motherboard slow• I/O always is the slowest part of

any program execution

Page 42: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: I/O Devices

Input devices:

Keyboard Mouse Others

Page 43: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: I/O Devices

Output devices:• Monitors

CRT monitors (almost obsolete) LCD and LED

• Printers• Others

Page 44: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: I/O Devices

Monitor’s quality Screen Size

(diagonal in inches)

Resolution (in pixels)

Setting the screen resolution.

Page 45: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: I/O Devices

Types of printers• Laser• Inkjet

B/W printing:

buy laser printers Color laser printer:

very expensive cartridges. Inkjet printer

Page 46: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Printer

Turn OFF the printer when not printing to prevent the heat from drying the ink cartridges.

Use the power button to turn off the printer in order to make cartridges stay in the proper housing. Do not pull the power cord.

Lase printers

Page 47: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Video Card Integrated (on-board) and

dedicated video cards Gaming: needs high-end video

cards. High-end computers have

dedicated video-cards Usually, a video card has its own

memory; on-board video shares main memory.

47Microsoft Office 2007-Illustrated Introductory, Premium Video Edition

Page 48: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Hardware: Network Devices Network cables (Ethernet cables)

Modems and routers Wireless cards and adapters Building a home wireless network:

Not as hard as one thinks. Just follow the instructions.

Page 49: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

A Desktop Computer

Page 50: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Motherboard and others

Page 51: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

The Back of a Computer

Computer ports and connections

Power connection

Mouse port

FireWire port

Network port

Phone line connection

Speaker and microphone connections

USB ports

Monitor port

Audio connection

Keyboard port

Page 52: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: major Components Operating system

• Windows• Unix & Linux (open and free)• MacOS

System utilities Application software

Page 53: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: Introduction

Software manipulates and processes data

Data:Strings, numbers, figures, sounds, images, and graphics…

Page 54: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: Introduction

File --- named collection of stored data.• Executable file can be run to perform

a specific task.• Data file contains data.

Everything in a computer is represented by a number on disk and in memory.

Page 55: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: Data Representations

Every English character is represented by an ASCII number.

ASCII numbers defined by ANSI. ANSI standard sample ASCII code

Page 56: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

56Microsoft Office 2007-Illustrated Introductory, Premium Video Edition

Software: Data Representations

ASCII --- American Standard code for Information Exchange

ANSI --- American National Standards Institute

Page 57: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: System Software

System software helps the computer carry out it s basic operating tasks.• Operating systems• Utilities (e.g. Compiler/Interpreter, Linker)• Device drivers• Programming languages

Page 58: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: System Software Operating system

• Executes programs• controls the input and output (I/O)• allocates system resources and priorities• Schedules tasks• manages files on storage devices• guards against equipment failure• provides a graphical user interface

(GUI)• Others

Page 59: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: System Software Operating system

• Programmer: develop and write the system

• System administrator (SA): configure and maintain the system

• End user: use the system Using GUI (Graphical User Interface) Manipulating files

Page 60: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

60

Software: System Software Major Operating systems

• Windows by Microsoft: most recent version is Windows 7.

• Unix/Linux: many flavors (Sun Solaris, HP-UX, IBM AIX, Redhat, Debian, Ubuntu…)

• MacOS: only for Apple computers.

Page 61: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

61

Software: System Software

Which OS is better?• Windows: most popular. Easy to use.

Many applications. Hardware/software installation is easy. Prone to virus attacks.

• Unix/Linux: free. Popular in academic world. Hardware/software installation needs effort and expertise. More secure than Windows.

• MacOS: nice GUI, stable and reliable. Pay a premium because it’s Apple.

Page 62: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

62

Software: System Software

We are users and we learn• Basic knowledge of file systems.• To use GUI of the system• To configure the system• To maintain the system

Page 63: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: System Software

Utilities • Analyze, configure, optimize and

maintain computer system: disk defragmenter, system restore…

Device drivers• “Drives” a specific device (drive). • The main task to install a device is to

install its driver.

Page 64: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

64Microsoft Office 2007-Illustrated Introductory, Premium Video Edition

Software: System Software

Programming languages• Used by a programmer to

develop programs. • Most commonly used computer

language: C, C++, Java, C#, Visual Basic, Fortran…

Page 65: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

65Microsoft Office 2007-Illustrated Introductory, Premium Video Edition

Software: System Software

Drive and Driver• Drive --- Hardware• Driver --- software to “drive” a

specific drive. Examples:

Hard (disk) drive --- Hard (disk) driverUSB drive --- USB driverPrinter --- Printer driver

Page 66: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: System Software

Windows Vista starting screen

Icons (you might see additional

icons on your

screen)

Start button

Taskbar

Quick Launch toolbar

Gadgets (small programs; you might see additional or different gadgets on your screen)

Page 67: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software: Application Software

Enables you to perform specific computer tasks

Examples: web browsers, Microsoft Office, DBMS, ……

Page 68: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: virus (malware) Software programs infesting

computers: Worms, Trojan horse, spyware, adware…

Replicates itself and fill up disks Damages computer systems Erases files and wipes out disks Ties up network and computers.

Slows down program execution

Page 69: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

69

Security Threats: viruses

Pops up ads Keylogger: steals personal

information Creates a back-door and lets

remote users access your computer

A bad virus spreads very fast and affects millions computers.

Page 70: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

70

Security Threats: Sources of viruses

Downloading virus-infected files Opening malicious emails and their

attachments Infected disks and CDs Worst incidents: Melissa, ILOVEYOU

Page 71: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Anti-virus Firewall

• Stop unwanted and unsolicited incoming network messages and data.

• Can be either hardware or software. Antivirus software

• Every computer must equip with an antivirus software.

System and software update:• Automatic update

Page 72: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

72

Security Threats: Antivirus

Microsoft: security_essentials (free) Paid: Norton, MacAfee, Trend Micro Free:

• ClamAV: open source. For Unix/Linux , also for Windows

• Clamwin: variant of ClamAV for Windows• Stopzilla• Avast!• AVG Anti-Virus• Malwarebytes• Etc…….

Page 73: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

73

Security Threats: Antivirus

There is no excuse not to install an antivirus software, at least it should have security_essential installed fromwww.microsoft.com/security_essential

SE is free and works well!

Page 74: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Spoofed sites Spoofed site

• A Web site set up to look like another Web site, but which does not belong to the organization portrayed in the site

• The URL (address on the Web) looks similar to a URL from the legitimate site www.citibank.com and www.citybank.com

• Usually set up to try to convince customers of the real site to enter personal information

Page 75: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Phishing Phishing

• Sending e-mails to customers of a legitimate Web site (banks and institutions) asking them to click a link in the e-mail because of Security upgrade Account update Account compromised Other reasons

• If the customer does not click the link, his/her account will be suspended or closed

• the link leads to a spoofed site and asks personal and/or login information.

Page 76: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Other tricks Nigerian scams

• Lottery winner, request processing fee• Unclaimed treasure: needs your account

number to deposit Over-payment scam

• You sell an item (a car…)• A far-away guy will buy it and send you a

bank check larger than your asking price• He asks you to mail the extra to himself

or someone else through western union…• You deposit the check and send the extra

back (real money). Several weeks later, the check bounced.

Page 77: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Phishing

Too good to be true >>> not true Never open an unsolicited email,

especially, its attachments Never reveal your personal information

(SSN, bank account number, credit number…) unless you initialize the communication

Never make any payment to a (faraway) stranger.

Wait for the check cleared, then take action.

If someone specifically ask you to send money through Western Union or Money Gram most likely it’s a scam.

Page 78: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Phishing

To clear a bank check needs one to several weeks, especially foreign checks.

Payment by Western Union… is not traceable.

78Microsoft Office 2007-Illustrated Introductory, Premium Video Edition

Page 79: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threat: Strong password At least eight characters long

Consists of upper- and lowercase letters and numbers

Does not include common personal information

Page 80: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Security Threats: Encryption

Encrypt important files especially when files are on a USB drive.

TrueCrypt: free and easy to use for Unix, Linux, and Windows.

Page 81: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Computer Languages

First generation: machine language

Second generation: Assembly language

Third generation: High level such as C, Fortran, C++, Java, VB…

Page 82: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

82

Programming languages

First generation: machine language: • Consists of 0’s and 1’s• The only language understood by computers• Fast and efficient• Very hard to program, read and understand.• Used in the old times.

Introduction to Programming

Page 83: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

83

Programming languages

Second generation: assembly language: • English words are used in a very cryptic way• Needs an assembler to convert it to machine

language• Relatively fast and efficient• Still hard to program, read and understand; but is

doable. The core parts of OS’s are usually coded in assembly language

• Different hardware (CPUs) has different assemblers

Introduction to Programming

Page 84: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

84

Programming languages

Third generation: high level language: • C, C++, Java, C#,VB, Fortran,…• English-like language• Developing programs by writing source code• Source code (compiler or interpreter) assembly

language (assembler) machine language • Still fast and efficient for most tasks• Relatively easy to program, read and understand• Portable to almost all platforms.

Introduction to Programming

Page 85: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010. 85

Translating LanguagesEnglish: Display the sum of A times B plus C.

C++: cout << (A * B + C);

Assembly Language:mov eax,Amul Badd eax,Ccall WriteInt

Intel Machine Language:A1 00000000F7 25 0000000403 05 00000008E8 00500000

Page 86: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

86

What are programs? A program is a sequence of instructions

written in computer languages to guide computers to perform tasks.

A computer follows the instructions exactly and precisely. --- an important observation of computer programming.

Introduction to Programming

Page 87: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

87

An example

To calculate the average of two numbers• Input: get the two numbers• Processing: calculate their average• Output: display the result

Introduction to Programming

Page 88: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software Development

Source code (text file) Interpreter and compiler

convert the source to object code (.obj)

Linker links all object codes and libraries into executable files. (.exe)

Page 89: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

89

Compiler and Interpreter

Compiler converts the whole program from source code to machine code, generates an executable program.• Source files object files (.obj)• A linker links all the object files and library functions an

executable program (.exe) Interpreter converts the source code one line/block

at a time and execute it.• Advantage: easy to develop and debug the program• Disadvantage: slow

Introduction to Programming

Page 90: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software Development

Java uses a different approach in order to make it portable.

Source code (text file, .java) Java compiler javac convert the

source to byte code (.class) Java Virtual Machine (JVM)

interprets the byte code and run the program.

Page 91: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

91

Write a fast program

The slowest part of a program is I/O:• Reduce I/O times as much as possible• Use buffers to do I/O

A fast computer make a program running fast: Fast CPU (32-bit vs. 64-bit) Big memory (32-bit machine can access only 3.7

Gb) Good video card if you like to play fast games

Introduction to Programming

Page 92: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentOOP and Procedural

• Object-Oriented Programming (OOP): Java

• Procedural (Conventional) programming: C

• What are the differences between them?

Page 93: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentClient and Server

• In a distributed environment• A server provides services• A client requests services• The opposite: peer-to-peer

system.

Page 94: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentLife Cycle

• Analysis and design• Coding• Testing and Debugging• Maintenance

Page 95: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentComments

• Line comments: starts with //, ends at the end of line

• Block comments: /* … */• Comments make the code

more readable and easy to understand.

Page 96: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentComponents of a program

• Basic: data types and operations,…

• Code structs: decisions, loops, functions

• Data structures: arrays, classes, and others.

Page 97: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Units of Memory and Storage

Computer understands 0 and 1 only: on/off state, N/S pole, 0/5 volts…

1 (“on”) and 0 (“off”) are referred to as bits.

A byte has eight bits. Two bytes represent a unique character (Unicode)

Page 98: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentMemory organization

Bit (0 or 1)Byte: 8 bits (0 to 255)Word: system dependentKilobyte: 1 k (1024) bytesMegabyte: 1 M byte (1024 x

1024)Pay attention to data types.

Page 99: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Units of Memory and Storage

Kilobyte (KB) = one thousand (1024) bytes

Megabyte (MB) = one million (1024 KB) bytes

Gigabyte (GB) = one billion bytes Terabyte (TB) = one trillion bytes

Page 100: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Data Representations

Everything is a number in the computer memory or on storages• Numbers numbers• Characters numbers by ASCII• Grey numbers (0-255)• Color three numbers (R/G/B)

Page 101: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Software DevelopmentNumber system

Binary number (0,1): base 2Octal number (0,1,2,…,7):

base 8Example: o1, o7, o23

Decimal number (0,1,2,…,9): base 10

Hexadecimal number (0,1,2,…,9,A,B,C,D,E,F)

Example: 0x1, 0x8, 0xf, 0xff

Page 102: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, 2010.

Character Storage

Character sets• Standard ASCII (0 – 127)• Extended ASCII (0 – 255)• ANSI (0 – 255)• Unicode (0 – 65,535)• (UTF-8, UTF-16, UTF-32)

Page 103: Introduction to Programming CST 112 Section 501 CRN:26108 Grant-Caumsett Hall 203 Monday 6:00 pm – 9:50 pm Welcome Aboard.

Start processing!


Recommended