CS100A, Fall 1998. Lec. 1, Tue. 1 Sept. 1 CS100A, Fall 1998 After discussing the notion of an algorithm and (computer) program briefly, the first lecture.

Slides:



Advertisements
Similar presentations
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Advertisements

CS 106 Introduction to Computer Science I 11 / 09 / 2007 Instructor: Michael Eckmann.
Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.
B-1 Lecture 2: Problems, Algorithms, and Programs © 2000 UW CSE University of Washington Computer Programming I.
1 Executing Method Calls This lecture tells you precisely how method calls are executed (a few details will have to wait until we get to classes and objects).
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
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.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
COMP 14: Primitive Data and Objects May 24, 2000 Nick Vallidis.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Computer Science 101 Introduction to Programming.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Introducing Java.
Imperative Programming
1. Reference  2  Algorithm :- Outline the essence of a computational procedure, step by step instructions.  Program :- an.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Computer Science 101 Introduction to Programming.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Programming With C.
Python From the book “Think Python”
ดร.สุรศักดิ์ มังสิงห์ SPU, Computer Science Dept.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
“The study of algorithms is the cornerstone of computer science.” Algorithms Fall 2011.
What does a computer program look like: a general overview.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Class 1: What this course is about. Assignment Read: Chapter 1 Read: Chapter 1 Do: Chapter 1 ‘workbook’ pages not finished in class Do: Chapter 1 ‘workbook’
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
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.
Procedural programming in Java Methods, parameters and return values.
Introduction to Methods. Previously discussed There are similarities in make up of that can help you remember the construct of a class a class in the.
A-1 © 2000 UW CSE University of Washington Computer Programming I Lecture 21: Course Wrap-up and Look Ahead.
Introduction to programming Carl Smith National Certificate Year 2 – Unit 4.
CS100A, Fall 1998 Key Concepts 1 These notes contain short definitions of the basic entities that make up a Java program, along with a description of the.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
The Hashemite University Computer Engineering Department
CS 100Lecture 11 Introduction to Programming n What is an algorithm? n Input and output n Sequential execution n Conditional execution Reading: Chapter.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Getting Started With Python Brendan Routledge
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Software Engineering Algorithms, Compilers, & Lifecycle.
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
Topic: Python’s building blocks -> Variables, Values, and Types
User-Written Functions
Concepts of Object Oriented Programming
CS100A, 10 Sept Lecture 4: Continue discussion of classes and introduces Class String, Printing output using System.out.print, System,out.println,
Lecture 2 Introduction to Programming
COMS W1004 Introduction to Computer Science and Programming in Java
CS190/295 Programming in Python for Life Sciences: Lecture 1
Computer Programming.
Chapter 10 Programming Fundamentals with JavaScript
15-110: Principles of Computing
Unit 3 lesson 2-5 The Need For Algorithms- Creativity in Algorithms – Simple Commands - Functions Day 18.
Tonga Institute of Higher Education IT 141: Information Systems
The structure of programming
Discrete Mathematics and its Applications
Tonga Institute of Higher Education IT 141: Information Systems
Type Topic in here! Created by Educational Technology Network
CS100A, Fall 1998 This lecture covers the declaration of variables, assignment, and the if statement. While discussing the declaration of variables,
Presentation transcript:

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 will introduce method calls, since method calls are mandatory when doing any I/O or graphics and since they are one of the most frequently used statements. First, we will discuss the heading of a method --the precise comment that specifies what the method does, prefix modifiers, name, and parameters. Throughout, the need for a precise specification will be emphasized, for without a precise specification, one can’t easily tell what the method does. Then, we will discuss method calls (invocations), using a substitution semantics: the method call does what the specification of the method says, but with parameters replaced by arguments of the call. We will discuss the fact that THEY (the students) could execute something like drawOval(5,5,4,3), if given the right color crayon and the graph paper on which to draw it. Something like drawOval(5,5,4,3) is simply shorthand for the comment of the method, with the parameters replaced by the arguments. We will illustrate this on the computer, using a small program that draws circles/squares and titles for them in a window. We will also step through execution of the program using the debugger, so they get the idea of sequential execution. A nice feature of using the debugger for this is that we can show what happens when the Drawing window is first covered by another window and then uncovered by moving the other window away: the Drawing window is now all messed up --but the system calls method paint in order to redraw that window! Thus, the students get a bit of a feel for what is going on behind the scenes when they move windows around. Necessarily, we will also mention integer arithmetic, but weleave a full explanation of integer expressions to the first section. We will explain carefully that many parts of a Java program will not be understandable at this point --prefix modifiers, classes, the “g.” on “g.drawOval(…)”, and so forth. These will all become clearer as the course progresses.

CS100A, Fall Lec. 1, Tue. 1 Sept. 2 CS100A, Fall 1998 Goal: learn to write intelligible and correct computer programs — effectively and efficiently. Main Language: Java (object oriented, cleaner and easier to use than C++). Software: Metrowerks CodeWarrior, on the Macintosh or the PC. Instructors: Gries & Cardie

CS100A, Fall Lec. 1, Tue. 1 Sept. 3 Main Concepts today: Algorithm, program. Method and method call. Graphics. Execution of a program. Executing using the debugger Reading: Holmes 2, 12-19, 25, Handout for assignment 0, Sect. 2-4 First assignment due: Tuesday, 8 Sept. at beginning of lecture!!!

CS100A, Fall Lec. 1, Tue. 1 Sept. 4 Algorithm: A set of instructions for performing some task. An algorithm is: precise unambiguous effective (always works) abstract Examples: A recipe for cooking soup. “Here’s a list of integers; tell me whether each one is even or odd.” Play a game of tic-tac-toe in a way that you never lose.

CS100A, Fall Lec. 1, Tue. 1 Sept. 5 Program: An algorithm that is written in some language: English, Sanskrit, C++, Java, FORTRAN, Pascal. Computer program: a program in a “computer language”, e.g. Java.

CS100A, Fall Lec. 1, Tue. 1 Sept. 6 An algorithm is usually given as a sequence of instructions to execute (in the order given). In a programming language like Java, each of these instructions is called a statement. One of the most frequent kinds of statement used in Java is the call of a method call, or method invocation. To understand a method call, we need to know a bit about what a method is. Terms sometimes used interchangeably: method procedure function

CS100A, Fall Lec. 1, Tue. 1 Sept. 7 // Draw a line from point (x1,y1) to // point (x2,y2) public void drawLine (int x1, int y1, int x2, int y2) Heading of a method: Comment: explains precisely what the method is to do. Written as a command to do it. Some prefix modifiers (public and void) --explained later The name of the method: drawLine. The parameters: x1, y1, x2, y2 (along with their types (int)).

CS100A, Fall Lec. 1, Tue. 1 Sept. 8 HEADING: // 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).

CS100A, Fall Lec. 1, Tue. 1 Sept. 9 HEADING: // Print the largest of x, y, and z public void printMax (int x, int y, int z) CALL: printMax(20, 5, 20-5*4); COMMAND TO BE EXECUTED: Print the largest of 20, 5, and 20-5*4. Note: the method name, printMax, has no meaning for Java. We could as well have used the name aaa, or w.

CS100A, Fall Lec. 1, Tue. 1 Sept. 10 HEADING: // 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”.

CS100A, Fall Lec. 1, Tue. 1 Sept. 11 Important points: 1. A method can have zero parameters. 2. Syntax of a method call: a name ( list of zero or more arguments (names), separated by “,” ) ; 3. To find out what a method call does, make a copy of the specification of the method (the comment in the heading) and replace all occurrences of the parameters by the arguments of the call.

CS100A, Fall Lec. 1, Tue. 1 Sept For this process to be effective, the specification (the comment) must be precise understandable correct (it must say exactly what the method actually does Rest of lecture: Demonstrate calls with a small Java program, using both run and debug.