Welcome to
CS 152L Computer Programming Fundamentals - In Java Instructor: Joel Castellanos e-mail:
[email protected] Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 1/15/2013
Textbook & Reading Assignment Java: An Introduction to Problem Solving and Programming (6th Edition) by Walter Savitch
Due Wednesday: Jan 16 Chapter 1: Intro to Computers & Java 1.1: Computer Basics 1.2: A Sip of Java 1.3: Programming Basics 1.4: Graphics Supplement
Due Wednesday: Jan 23 Lab 1 (on Thursday or Friday): Your Name in ASCII Art
2.1 Variables and Expressions 2.2 The Class String
2
1
Announcements: Note taker THE OFFICE OF ACCESSIBILITY RESOURCE CENTER IS LOOKING FOR A STUDENT IN THIS CLASS TO VOLUNTEER TO PROVIDE NOTES FOR THIS CLASS. THE STUDENT WILL BE PAID A STIPEND FOR THE SEMESTER. INTERESTED STUDENT SHOULD COME BY OUR OFFICE AT 2021 MESA VISTA HALL TO COMPLETE THE REQUIRED HIRING PAPERWORK.
3
WebCT Login: http://vista.unm.edu/
Announcements (i.e. class canceled) Assignments Calendar Discussion My Grades My Files 4
2
http://cs.unm.edu/
5
CS Mailing Lists
csundergrad csgrad cssports ■ CS Job announcements ● UNM departments ● Sandia National Labs ● Greater Albuquerque community ■ Social Activities 6
■ Cooperate Visits
3
Course Description CS-152 is an introduction to the art of computing. The course objectives are understanding relationships between computation, problem solving, and programming using Java. Computer Programmer Fluency
Common hardware and software What types of problems are easy / hard for computers? How are computer solutions designed?
Programming
Conditional control flow: if, else if, else logic, for loops and while loops.
Have some fun with Multimedia and Game authoring. Not a course on Object Oriented Programming nor on the myriad of Java classes.
7
CS-152 Prerequisite Skills CS-152 should not be your first course in computer
programming - unless you like very challenging courses. Basic computer literacy: mouse, keyboard,
downloading and installing software, ... Some programming experience in some computer
language or special aptitude for programming, or experience with challenging courses (i.e. AP Physics, Calculus, ...) Solid understanding of Algebra I. 8
4
Options other than CS-152 CS-105 (Python) First course in computer programming with
emphases on multimedia. CS-151 (Matlab) First course in computer programming with
emphases on scientific / engineering programming. CS-390 (NetLogo) First course in computer programming
with emphases modeling. If you have a solid grasp of control flow and problem solving
9
in, any programming language, skip CS-152. Take CS-251 (not CS-241 - this should come after 251). CS-251 (Java) Intermediate Programming, Object Oriented Programming. A CS major who skips CS-152, will need to take an extra CS elective.
We will use i-clicker for quizzes in lecture only. We will use i-clicker every lecture. For CS-152, Register your i-clicker using your UNM NetID (NOT your
Student ID). Register your name as it appears in LoboWeb. Some classes may require you to register in a different way or with a
different ID number. If so, register again for this class in this way. One i-clicker can be registered and shared by more then one person
(as long as no two of them are in an i-clicker class at the same time). If you know of a way for your phone or some other device to be used
10
- without me needing to buy/bring additional equipment, I am open to using it.
5
Web Registration http://www.iclicker.com/support/registeryourclicker Your UNM NetID does NOT include @unm.edu Use Correct Capitalization
Hexadecimal: Only decimal digits 0-9 and letters A through F. NO OTHER LETTERS
UNM NetID In this field, you MUST enter your UNM NetID, NOT your student ID !!!
11
The Emptiness of "Registration Successful" After entering name, NetID and Remote ID, the iclicker registration page tells you "Registration Successful". If you think about it, you will realize just how empty that statement is. The website does not know your name. If, for example, you had entered Justin Bieber as your name, the program would have said "Registration Successful". Then, when I enter grades in WebCT, I do not know that the points earned by Justin Bieber actually belong to you. Thus, you get a zero for what the website calls "Registration Successful". 12
The same is true if you enter the incorrect NetID or if you enter the incorrect Remote ID.
6
Quiz Question #1: Do you have your i-clicker? a) Yes – I am ready to go. b) I bought one from the bookstore, but forgot it. c) My dog ate it. d) No – I did not get one yet. e) What is an i-clicker anyway? 13
Forgotten i-clicker? If you forget your i-clicker, you may borrow one of
my loner i-clickers. Each loner i-clicker has an animal picture. If you borrow an i-clicker, then to get credit, you
must e-mail me on the same day:
Subject: CS-152 borrowed i-clicker
Body: Name, Date, and Animal.
Loner i-clickers are not intended to replace buying
an i-clicker or a lost i-clicker. 14
7
Course Grading 45% Programming Labs and Projects 45% Exams (Midterm & Final) 10% Lecture i-clicker quizzes
Approximately 40, attendance required.
Missed quizzes cannot be made up – for any reason!
Attendance is required in both lecture and Lab. First 3 lab classes missed: no direct grade impact. After 3 missed lab classes: -2 to final grade / missed lab
class. Minimum lab grade of 10/20 for attended labs. 15
Turning In Assignments All assignments must be submitted into WebCT. e-mailing code is useful for getting help with debugging, but
an assignment turned in by e-mail counts for nothing . Late projects/assignments receive a 5% per day penalty:
Regardless of the reason. An assignment is “turned in” on the WebCT date stamp of
the final version submitted. Assignments can be turned in after the due date, but not
after the cut-off date. The cut-off date is 7 days after the due date. 16
8
Assignment Grading In general, assignments are graded by your lab
instructor. When you have a question about how something
was graded, first, ask the person who graded it (this will display with the grade in WebCT). The lab instructors must follow strict grading rubrics
to score your assignments. If you feel you deserve more points than the rubric
gives, then explain why to me. I do make exceptions. 17
Always Verify WebCT Submissions When you attach your homework document into in WebCT, do
not forget to click Submit !!! It is your responsibility to verify that your submit worked. After submitting, Exit WebCT. Log back in. Check that your file is are attached. Check that the contents of the submission are what you expect
them to be.
18
Open and examine carefully.
Make sure you submitted the correct version.
Up until the assignment due date, you can take back your submission, and resubmit.
9
WebCT: Take Back Submission
19
Work Together but do not Cheat Working together and helping one another on all
projects is highly encouraged. This includes discussion of project:
specification,
algorithms,
data structures,
and test cases.
Do not share code. It is considered cheating to leave your code (paper or
electronic copies) where others can find it. You responsible for the security of your intellectual property. 20
Do not have anyone else write code for you.
10
In the Computer it is All Just Numbers Bach's Sonata
No. 5 in F minor Owl City's
Fireflies The motion
picture: Shrek Forever After Hamlet, Prince of
Denmark. World of Warcraft 21
A computer file is just a list of 1s & 0s
22
11
Computers Do Simple Things Set the intensity of the red, green and blue light given off by
a particular pixel on a display. Send a precisely timed sequence of hi and low voltage
values to a hard disk controller, USB port, or wireless transmitter. Add, Subtract, Multiply or Divide two numbers.
Voltage
Read or Set the voltage state of a particular memory circuit. Time
23
Complexity from Simplicity The complex things we see computers do are the
results of programs. Even “short” programs are huge and complex lists of
simple computer instructions.
24
push mov mov sub mov out xor mov out jmp SIGINC: mov
dx bx,ax ax,_dt_ymppr ax,bx dx,TIMER1_CNT dx,ax ax,ax dx,TIMER0_CNT dx,ax VAMOS1
Code sample for 8086 assembler
_dt_ymdydx,UP
12
Programming Language A programming language is a set of symbols and rules designed for humans to more easily represent computer instructions.
Java code using standard class libraries: 25
Toolkit tk = Toolkit.getDefaultToolkit(); Image img = tk.getImage("C:/Users/Joel/Art/coin.gif");
Computer Programs and Recipes Like a recipe, say for cooking quiche, a computer program
is a sequence of steps. In a recipe, conditional logic, if it exists at all, is trivial. For
example: 1. Bake for 50 minutes. 2. Remove from oven. 3. Press a knife into the center and remove. If bits of egg cling to the knife, then return quiche to oven and bake for another 10 minutes. 4. Repeat this until the knife comes out clean. In a computer program, it is common for there to be 100s 26
or 1000s of conditions with complex nestings and other interrelations.
13
Syntax Errors in English “Having caught sight of the wolves, he ran quick.”
“Make me a milkshake.”
“The panda eats, shoots and leaves”. 27
Programming vs Natural Language The entire Java vocabulary consists of 52 reserved words. There are many Java classes, such as Toolkit and
Image. However, these are the proper nouns of the language. A person can be fluent in a language without knowing the
vast majority of its proper nouns. Proper nouns are learned as needed, and can be forgotten
when no longer needed. Like natural languages, programming languages have
28
punctuation and syntax rules (e.g. In Java, every statement is ended with a semicolon). Programming languages, however, have much fewer rules than natural languages.
14
Small Language with Complex Usage Programming Languages are
much smaller and easier to learn than natural languages. However, programming
languages are primarily used to express complex branchings of conditional logic that far surpass common uses of natural languages. Logic skills have strong
carryover from one programming language to another. 29
Programming verses Software The act of authoring a computer program is much more like the act of writing an essay than learning to use software such as Photoshop, PowerPoint or World of Warcraft.
30
Software, such as Photoshop, is often learned by "click and explore"
15
Logic What makes computer programming hard is learning to
work with complex logic. Great books to help develop logic skills:
The Republic by Plato, 360.
The Elements by Euclid, 300 B.C.
St. Thomas Aquinas on Politics and Ethics, essays from 1269-1272
The Problems of Philosophy by Bertrand Russell, 1912
The Selfish Gene by Richard Dawkins, 1976
31
Window into How Computers Think Easy: Using only standard arithmetic operations, it takes no more than a few hours to write a Java program that can solve large systems of differential equations. Such a Java program running on a low-end desktop computer can calculate the solution of such a system from a given initial value in less than a second. Hard: Being given a bunch of photographs of everyday life, the worlds most powerful computer running the worlds best artificial intelligence software is currently incapable of deciding this is a photo of a woman walking a dog.
32
16