Introduction to Programming

advertisement
SWTJC STEM
Welcome to ENGR 2304/COSC 1336
Engineering Programming
Want to be a “Lean, mean programming machine . . .”
Chapter 1-1 cg 1
SWTJC STEM
•
•
Welcome to ENGR 2304/COSC 1336
Engineering Programming
My name is Dick Whipple
•
BSEE, MSEE from UH
•
Designed and programmed computers for 25 years
The course, ENGR 2304/COSC 1336 . . .
•
Is designed as a first programming course.
•
Is widely accepted for transfer.
•
Will use Java as the programming language.
•
Will focus on engineering problem solving.
•
Is WebCT enhanced with lab on Internet.
Chapter 1-1 cg 1
SWTJC STEM
Very Important Information
Objectives for Thursday
• Access course on my website
http://tech.swtjc.net/whipple_online/
• Logon to WebCT & this class
http://70.241.209.12/webct/public/home.pl
• Add both links to your favorites!
• Review the syllabus
• Start Assignment 1
• Read Chapter 1-1 of the text, Java Software
Solutions by Lewis and Loftus
• Install JBuilder from CD-ROM
Chapter 1-1 cg 1
SWTJC STEM
Class Attendance
• Attend class regularly
• Class begins promptly At 8:00 AM
• Class WebCT enhanced including . . .
• Access to study materials
• Lecture PowerPoints
• Videos
• Other readings
• Complete/submit lab assignments
Chapter 1-1 cg 1
SWTJC STEM
Demonstrate Responsibility
• Read and follow instructions to the letter.
• Read and study all assigned “Text Readings”.
• Research the Internet as directed.
• Utilize WebCT as an enhancement to the course.
• Ask questions when you don’t understand.
• Complete work on time and without weak
excuses.
• Take your first steps as a “Professional”!
Chapter 1-1 cg 2
SWTJC STEM
Computers Are Not Magic
"There is nothing magic about computers. Any answer that a
computer can arrive at could also be arrived at by a human if
he/she lived long enough, had enough pencils, etc. What's
important to remember is that, regardless of the speed at which a
computation is done, the process is a straightforward, one step at a
time, matter."
"That isn't to say that a person or persons can solve any
problem a computer can. Sometimes temporal (time)
problems are a part of the problem. The numbers which tell
the rockets of a space ship what to do after the first stage lets
go can't take six months for a human to compute with paper
and pencil. If more than a second or so is required, a satellite
may be falling down someone's chimney."
Michael Kennedy and Martin B. Solomon
Chapter 1-1 cg 3
SWTJC STEM
Communicating with Computers
"A person who wants to use a computer must learn to be
precise. One does not communicate with a computer by hand
waving and mumbling. A computer can be of service only if it
is instructed carefully and according to preset rules."
Michael Kennedy and Martin B. Solomon
As a student in ENGR 2304, I expect you to follow this
admonition to the letter.
If you are not willing to do so, this class may not be for you!
Chapter 1-1 cg 3
SWTJC STEM
Purpose of a Programming
Language
•
The purpose of a programming language is to
facilitate communication between humans and
computers.
•
Computers are very accurate and fast at following
instructions, but understand only “bits and bytes”.
•
Humans know what instructions to give, but cannot
easily give them to computers in “bits and bytes”.
•
Computer languages bridge the gap!
Chapter 1-1 cg 3
SWTJC STEM
Examples of Programming
Languages
•
Java, Visual Basic, & C++ are multipurpose languages.
•
Fortran & Aida are scientific languages.
•
Cobol is a business language.
•
Assembly languages create fast, compact code for 3D
animation and gaming.
•
Markup languages like HTML are Internet based.
•
Scripting languages like JavaScript perform utility duty.
Chapter 1-1 cg 3
SWTJC STEM
History of Java
•
Developed at Sun Microsystems in early 1990’s.
•
Development team led by James Gosling.
•
Originally called Oak and used in embedded
consumer electronic applications.
•
In 1995 renamed Java and redesigned for Internet
applications.
•
Gained renown as a general purpose programming
language.
Chapter 1-1 cg 4
SWTJC STEM
Characteristics of Java
•
Simple, modeled after C++ but easier to use
•
Object oriented, not procedural.
•
Distributed, adaptable to networking environments
•
Interpreted, runs on almost all computers
•
Robust & reliable; emphasizes error checking & good habits
•
Secure, will not damage a computer
•
Architecture neutral, platform independent
•
Portable, runs without being recompiled
•
Performance good though not the fastest
•
Multithreaded, performs several tasks at once
•
Dynamic, adapts to evolving environment
Chapter 1-1 cg 5
SWTJC STEM
Java’s Relationship with
World Wide Web
•
HTML is the authoring language for WWW.
•
Java programs run from browser.
•
Java makes the web environment “smarter”.
•
Java adds responsiveness and interactivity.
•
Java uses modern GUI interface.
•
Java enhances web graphics.
•
Java allows the web page to respond to user events.
Chapter 1-1 cg 6
SWTJC STEM
Java Development Environments
•
Sun Microsystems provides JDK (Java Toolkit)
•
JDK is basic and simple, but inefficient as design tool.
•
Other environments are better
•
NetBeans from Sun
•
JBuilder from Borland (we will use this!)
•
Visual Café from Webgain
•
Visual Age from IBM
•
Visual J++ from Microsoft
Chapter 1-1 cg 7
SWTJC STEM
IDE NetBeans
NetBeans provides an IDE (Integrated Development Environment)
that is . . .
•
Easy to learn
•
Simple to use
•
Adaptable to user requirements
•
Readily navigated to access . . .
•
packages
•
projects
•
programs
•
classes
•
code elements
Chapter 1-1 cg 7
SWTJC STEM
Installing NetBeans
• Download NetBeans from:
http://java.sun.com/javase/downloads/netbeans.html
• Run the “.exe” file
• You’ll be ready to “Run” your first program in not time!.
Chapter 1-1 cg 8
SWTJC STEM
Elements of AppBrowser Window
Chapter 1-1 cg 9
SWTJC STEM
•
•
Types of Java Programs
Application - A stand alone program written with a high
level language such as Java.
•
Executed from the computer by a Java interpreter
•
Not subject to security restrictions
•
Must contain a “main” method
Applet - Special kind of Java program that runs from a web
browser or applet viewer.
•
Subject to security restrictions
•
Cannot make changes to user’s system
•
Cannot read or write files
•
Cannot transmit computer viruses
Chapter 1-1 cg 10-14
SWTJC STEM
Java Program Components
Java’s programming components:
Packages - Collection of classes (Programs)
Classes - Collections of data and methods that operate on data
Methods - Collections of statements that operate on
data
Data
Variables - Stores data
Constants - Stores data that doesn’t change
Literals - Explicitly given data
{
Chapter 1-1 cg 10-14
SWTJC STEM
Java Programming Process
1. Create source code.
 Programmer creates source.
 Stores in filename.java .
2. Compile source.
 Converts source code to bytecode.
 Stores in filename.class. (Ready to execute.)
3. Execute bytecode in filename.class.
Chapter 1-1 cg 10-14
SWTJC STEM
Steps to Create a Program
1. Create a Java project.
2. Create a Java application program.
1) Create a new class.
2) Create the main method.
3. Compile and execute – “Run” the application.
Chapter 1-1 cg 10-14
SWTJC STEM
First Program with JBuilder
/*
My First Program
*/
public class HelloWorld
{
public static void main(String[] args)
{
// Declare variables
// Input data
// Process data
// Output Results
System.out.println("Hello World");
}
}
Chapter 1-1 cg 10-14
SWTJC STEM
What to do now?
•
Click on “Online Classes” at SWTJC’s homepage.
•
Click on “Class Schedule and find this class.
•
Link to my homepage and click on ENGR 2304.
•
Follow the instructions there for New Students.
•
Complete Assignment 1 by Thursday, February 4, 2010.
Chapter 1-1 cg 10-14
Download