CS 100Lecture 11 Welcome to CS 100 n Goal: Learn to write intelligible, correct computer programs n Language: Java (but the language should not be the.

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

Today’s Agenda  Syllabus CS2336: Computer Science II.
CSE Spring 2015 INTERMEDIATE PROGRAMMING
Introduction to Computer Programming I CSE 113
Lecture 2: Fundamental Concepts
Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Class 1: What this course is about. Assignments Reading: Chapter 1, pp 1-33 Do in Class 1: –Exercises on pages 13, 14, 22, 28 To hand in in Class 2: –Exercises.
CS 201 Functions Debzani Deb.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Genome Sciences 373 Genome Informatics Quiz Section #1 March 31, 2015.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Concept of Computer Programming November 2, 2011.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CSE 131 Computer Science 1 Module 1: (basics of Java)
Introducing Java.
Welcome to CS 115! Introduction to Programming. Class URL Please write this down!
CSE 1340 Introduction to Computing Concepts Class 2.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
CSc 2310 Principles of Programming (Java) Dr. Xiaolin Hu.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
Invitation to Computer Science, Java Version, Second Edition.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
Welcome to CS 115! Introduction to Programming. Class URL
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
By the end of this session you should be able to...
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
CS 101: Introduction to computer programming and utilization Abhiram Ranade.
Computer Science 102 Data Structures and Algorithms CSCI-UA.0102 Fall 2012 Lecture 1: administrative details Professor: Evan Korth New York University.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Introduction to programming in the Java programming language.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
1 CS 101 Today’s class will begin about 5 minutes late We will discuss the lab scheduling problems once class starts.
CS100A, Fall Lec. 1, Tue. 1 Sept. 1 CS100A, Fall 1998 After discussing the notion of an algorithm and (computer) program briefly, the first lecture.
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
WELCOME To ESC101N: Fundamentals of Computing Instructor: Ajai Jain
CS 100Lecture 11 Introduction to Programming n What is an algorithm? n Input and output n Sequential execution n Conditional execution Reading: Chapter.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Welcome to CS 115! Introduction to Programming Spring 2016.
C++ Programming Basics C++ Lecture 1 Stacy MacAllister.
CSC 241: Introduction to Computer Science I
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Welcome to CS 1010! Algorithmic Problem Solving.
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CS190/295 Programming in Python for Life Sciences: Lecture 1
Welcome to CS 1010! Algorithmic Problem Solving.
Welcome to CS 1010! Algorithmic Problem Solving.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Welcome to CS 1301! Principles of Programming I.
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Instructor: Alexander Stoytchev
Zorah Fung University of Washington, Winter 2016
CSC 241: Introduction to Computer Science I
Presentation transcript:

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

CS 100Lecture 12 Course Staff n Instructor: Lynette Millett, n TAs: – –Wei Tsang Ooi, – –Alan Renaud, – –David Welte, n Consultants: – – Rocky Chen, Young Ho Cho, Amanda Waack,

CS 100Lecture 13 Logistics n Lectures every day (Mon-Fri) n Roughly two assignments per week –NO LATE ASSIGNMENTS ACCEPTED n 0 or more short quizzes per week n Partners: 1 partner allowed where specified n Highest level of academic integrity expected

CS 100Lecture 14 Logistics continued n Office hours: as noted on web n One prelim: Monday, July 19, 1999 n Final Grades: –50% assignments –25% prelim –25% final n First Assignment due this THURSDAY

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

CS 100Lecture 16 Main Concepts Today n What is an algorithm? n Method and method call n Reading this week: Chapter 1 (skim), Chapters 2 and 3 n Handouts

CS 100Lecture 17 Algorithm n A set of instructions for performing some task that is: –precise –unambiguous –effective –abstract n In other words: well-specified

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

CS 100Lecture 19 Star Wars example: n First SW name: Write first 3 letters of your last name then attach first 2 letters of your first name n Last SW name: Write first 2 letters of mother’s maiden name and attact first 3 letters of hometown Lynette Millett born in Norway, ME to I. (Rogers) Millett becomes: Mil+Ly = Milly Ro+Nor = Ronor

CS 100Lecture 110 Ambiguous Algorithm n Take two pieces of bread n Put peanut butter on one side of one piece n Put jelly on one side of the other piece n Put the pieces together n Output of this algorithm is....

CS 100Lecture 111 A Messy Sandwich n Why? n 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 n Computers do exactly what they’re told or, worse, something undefined n Precision is important n Any other ambiguities in that example?

CS 100Lecture 112Programs n A program is an algorithm written in some language: English, C++, Java,.. n “Computer program” is a program in a computer language such as Java n Abstraction vs. Representation –Algorithm -- Program –Number -- Numeral –Object having “threeness” -- 3, III, three, |||

CS 100Lecture 113 How does it work? n Algorithm given as sequence of instructions to execute in order n In Java, each instruction is called a statement n Common statement in Java is a method call or method invocation n But, what’s a method? n “Method”, “procedure”, “function” often used interchangeably

CS 100Lecture 114 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

CS 100Lecture 115 Method Call Call: drawLine(3, 5, 1, 1); Call: drawLine(3, 5, 1, 1); n Command to be executed: Draw a line from point (3,5) to point (1,1) // Draw a line from point (x1, y1) to point //(x2, y2) public void drawLine (int x1, int y1, int x2, int y2)

CS 100Lecture 116 Another Example Call: printMax(7, 83, 20*5-52); Call: printMax(7, 83, 20*5-52); n Command to be executed: print the largest of 7, 83 and 20*5-52 n 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... // Print the largest of x, y and z public void printMax (int x, int y, int z)

CS 100Lecture 117 Yet Another Example Call: printHello(); Call: printHello(); n Command to be executed: In the output window, skip a line and print “Hello!” // In the output window, skip a line and print // “Hello!” public void printHello()

CS 100Lecture 118 Points to Remember n A method can have zero parameters n Syntax of a method call is: name ( list of 0 or more arguments separated by commas ) ;

CS 100Lecture 119 What does the Method do? n 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 n This assumes the programmer wrote good comments

CS 100Lecture 120 Understanding Methods n The way we have understood these methods relies on comments that are –precise –understandable –correct n Your programs will be judged partially on how well your documentation is

CS 100Lecture 121 Reading n 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. n URL:

CS 100Lecture 122 Assignment W1 n Series of questions requiring written answers n Should be fairly straightforward if you’ve done the reading n Due Thursday July 1 at the beginning of class

CS 100Lecture 123 Registration Form n Please fill out and turn in before you leave class today.