Welcome to CS 100 - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Welcome to CS 100

Description:

Language: Java (but the language should not be the primary focus) ... A recipe for chocolate mousse. Given this list of integers, tell me which ones are even ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 24
Provided by: Mill1
Category:
Tags: mousse | welcome

less

Transcript and Presenter's Notes

Title: Welcome to CS 100


1
Welcome to CS 100
  • Goal Learn to write intelligible, correct
    computer programs
  • Language Java (but the language should not be
    the primary focus)
  • Software CodeWarrior
  • Plan Compressed, intense version of a
    full-semester course. Be sure to keep up!

2
Course Staff
  • Instructor Lynette Millett, millett_at_cs
  • TAs
  • Wei Tsang Ooi, weitsang_at_cs.cornell.edu
  • Alan Renaud, ajr5_at_cornell.edu
  • David Welte, dcw6_at_cornell.edu
  • Consultants
  • Rocky Chen, pjc4_at_cornell.edu, Young Ho Cho,
    yc102_at_cornell.edu, Amanda Waack, amw18_at_cornell.edu

3
Logistics
  • Lectures every day (Mon-Fri)
  • Roughly two assignments per week
  • NO LATE ASSIGNMENTS ACCEPTED
  • 0 or more short quizzes per week
  • Partners 1 partner allowed where specified
  • Highest level of academic integrity expected

4
Logistics continued
  • Office hours as noted on web
  • One prelim Monday, July 19, 1999
  • Final Grades
  • 50 assignments
  • 25 prelim
  • 25 final
  • First Assignment due this THURSDAY

5
When Turning in Assignments
  • No late assignments accepted
  • Your name and Cornell ID should be on frontpage
    (in comments, if a program)
  • For programming assignments turn in printout of
    source code, sample output and disk
  • For written assignments please type. TAs reserve
    right not to grade illegible homework.

6
Main Concepts Today
  • What is an algorithm?
  • Method and method call
  • Reading this week Chapter 1 (skim), Chapters 2
    and 3
  • Handouts

7
Algorithm
  • A set of instructions for performing some task
    that is
  • precise
  • unambiguous
  • effective
  • abstract
  • In other words well-specified

8
Examples of Algorithms
  • A recipe for chocolate mousse
  • Given this list of integers, tell me which ones
    are even
  • Play a game of tic-tac-toe in a way that you
    never lose
  • Find your Star Wars name

9
Star Wars example
  • First SW name Write first 3 letters of your last
    name then attach first 2 letters of your first
    name
  • Last SW name Write first 2 letters of mothers
    maiden name and attact first 3 letters of hometown

Lynette Millett born in Norway, ME to I. (Rogers)
Millett becomes MilLy Milly RoNor Ronor
10
Ambiguous Algorithm
  • Take two pieces of bread
  • Put peanut butter on one side of one piece
  • Put jelly on one side of the other piece
  • Put the pieces together
  • Output of this algorithm is. . . .

11
A Messy Sandwich
  • Why?
  • The algorithm did not specify that the pieces of
    bread should be put together so that the peanut
    butter and jelly are on the inside
  • Computers do exactly what theyre told or, worse,
    something undefined
  • Precision is important
  • Any other ambiguities in that example?

12
Programs
  • A program is an algorithm written in some
    language English, C, Java, . .
  • Computer program is a program in a computer
    language such as Java
  • Abstraction vs. Representation
  • Algorithm -- Program
  • Number -- Numeral
  • Object having threeness -- 3, III, three,

13
How does it work?
  • Algorithm given as sequence of instructions to
    execute in order
  • In Java, each instruction is called a statement
  • Common statement in Java is a method call or
    method invocation
  • But, whats a method?
  • Method, procedure, function often used
    interchangeably

14
Sample Method Heading
// Draw a line from point (x1, y1) to point
//(x2, y2) public void drawLine (int x1, int
y1, int x2, int y2)
  • Comment explains the method precisely in
    English. Always begin with //
  • Prefix modifiers public, void (will explain
    later)
  • Method name drawLine
  • Parameters x1, y1, x2, y2, and their types int

15
Method Call
// Draw a line from point (x1, y1) to point
//(x2, y2) public void drawLine (int x1, int
y1, int x2, int y2)
  • Call drawLine(3, 5, 1, 1)
  • Command to be executed Draw a line from point
    (3,5) to point (1,1)

16
Another Example
// Print the largest of x, y and z public void
printMax (int x, int y, int z)
  • Call printMax(7, 83, 205-52)
  • Command to be executed print the largest of 7,
    83 and 205-52
  • Note the method name printMax has no meaning
    to Java. It is just a string of characters. We
    could have called it aaa, pm, mymethod, etc. . .

17
Yet Another Example
// In the output window, skip a line and print //
Hello! public void printHello()
  • Call printHello()
  • Command to be executed In the output window,
    skip a line and print Hello!

18
Points to Remember
  • A method can have zero parameters
  • Syntax of a method call is name(list of 0 or
    more arguments separated by commas)

19
What does the Method do?
  • To find out what a method does
  • Make a copy of the specification (the comment in
    the heading)
  • replace all parameters by the appropriate
    arguments in the call
  • This assumes the programmer wrote good comments

20
Understanding Methods
  • The way we have understood these methods relies
    on comments that are
  • precise
  • understandable
  • correct
  • Your programs will be judged partially on how
    well your documentation is

21
Reading
  • From now on, consult syllabus and/or webpage. We
    will try to point out appropriate readings from
    the text, but you should use the text as a
    reference when solving homework problems.
  • URL http//www.cs.cornell.edu/cs100-su99

22
Assignment W1
  • Series of questions requiring written answers
  • Should be fairly straightforward if youve done
    the reading
  • Due Thursday July 1 at the beginning of class

23
Registration Form
  • Please fill out and turn in before you leave
    class today.
Write a Comment
User Comments (0)
About PowerShow.com