1 / 23

Welcome to CS 100

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!. Course Staff.

kburke
Download Presentation

Welcome to CS 100

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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! Lecture 1

  2. Course Staff • Instructor: Lynette Millett, millett@cs • TAs: • Wei Tsang Ooi, weitsang@cs.cornell.edu • Alan Renaud, ajr5@cornell.edu • David Welte, dcw6@cornell.edu • Consultants: • Rocky Chen, pjc4@cornell.edu, Young Ho Cho, yc102@cornell.edu, Amanda Waack, amw18@cornell.edu Lecture 1

  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 Lecture 1

  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 Lecture 1

  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. Lecture 1

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

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

  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 Lecture 1

  9. Star Wars example: Lynette Millett born in Norway, ME to I. (Rogers) Millett becomes: Mil+Ly = Milly Ro+Nor = Ronor • 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 mother’s maiden name and attact first 3 letters of hometown Lecture 1

  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. . . . Lecture 1

  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 they’re told or, worse, something undefined • Precision is important • Any other ambiguities in that example? Lecture 1

  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, ||| Lecture 1

  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, what’s a method? • “Method”, “procedure”, “function” often used interchangeably Lecture 1

  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 Lecture 1

  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) Lecture 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, 20*5-52); • Command to be executed: print the largest of 7, 83 and 20*5-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. . . Lecture 1

  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!” Lecture 1

  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); Lecture 1

  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 Lecture 1

  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 Lecture 1

  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 Lecture 1

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

  23. Registration Form • Please fill out and turn in before you leave class today. Lecture 1

More Related