Instructor: Craig Duckett

Size: px
Start display at page:

Download "Instructor: Craig Duckett"

Transcription

1 Instructor: Craig Duckett

2 Announcements Assignment 1 Due Lecture 5 by MIDNIGHT I will double dog dare try to have Assignment 1 graded and back to you by Wednesday, January 24 th hopefully sooner! You betcha! 2

3 Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) Section 1: Monday, January 22 nd The Fickle Finger of Fate Assignment 2 (LECTURE 8) Section 1: Wednesday, January 31 st Assignment 1 Revision (LECTURE 10) Section 1: Wednesday, February 7 th Assignment 2 Revision (LECTURE 12) Section 1: Wednesday, February 14 th Assignment 3 (LECTURE 13) Section 1: Wednesday, February 21 st Assignment 3 Revision (LECTURE 16) Section 1: Monday, March 5 th Assignment 4 (LECTURE 18) NO REVISION AVAILABLE! Section 1: Monday, March 12 th 3

4 Today's Topics: Mish-Mash Some More Methods to Use Making Decisions in Java If statements While statements If/Else ( Either-or ) statements Comparison Operators Logical NOT operator! Intro to Variables and Parameters 4

5 And Now the "Warm Up" Quiz 5

6 REFRESHER Extending a Class 6

7 Another Look at Extending a Class Robot Robot object can do A move(); B turnleft(); C pickthing(); extends MrRoboto MrRoboto object can do A B C and new methods X turnaround(); Y move3(); Z turnright(); Remember: you can name the new class you re extending anything you want (with provisions depending on whether it s a file with only one class in it or with two or more classes in it). I named my class MrRoboto because I like the song by Styx. 7

8 Another Look at Extending a Class Robot extends MrRoboto Can do A B C Can do A B C and new methods X Y Z So, if you want a robot that can only do A, B, and C, then instantiate: Robot lisa = new Robot(bothell, 3, 2, Direction.SOUTH); But, if you want a robot that can do A, B, and C and X, Y, and Z, then instantiate: MrRoboto lisa = new MrRoboto(bothell, 3, 2, Direction.SOUTH); 8

9 Another Look at Extending a Class 9

10 Some More Methods (Robot Class) 10

11 Some More Methods (Robot Class) Up until now we ve been making use of just a few Robot class methods, like move(), turnleft(), putthing(), and pickthing(), as well as some new methods we might have created like turnaround(), move3(), or turnright(). Here are some additional Robot class methods that we are going to start introducing into our programs: frontisclear() Checks to see if the front is clear countthingsinbackpack() Checks number of things in backpack canpickthing() Checks to see if a thing is on intersection getdirection() Checks the direction the robot is facing getstreet() Checks the street number robot is on getavenue() Checks the avenue number robot is one How these can be used in a program will make more sense after I ve finished discussing the if and while statements in the next portion of the lecture Go to Becker Library: Select becker.robots from top left column, then Robot from bottom left column, then scroll over to the Method Summary section in the center right window 11

12 Basic Decision-Making Lewis Carroll (Charles Dodgson)

13 Chapter 4.1: Two Kinds of Decisions If and While Statements Use an if statement to perform an action once or not at all. Use a while statement to perform an action zero or more times. Use an if-else statement to perform either one action or another action. Use a while statement to perform an action a specified number of times. Up to now, a robot s exact initial situation was known at the start of a task. When we wrote our programs, this information allowed robots to find things and avoid running into walls. However, these programs worked only in their specific initial situations. If a robot tried to execute one of these programs in a slightly different initial situation, the robot would almost certainly fail to perform the task. To address this situation, a robot must make decisions about what to do next. Should it move or should it pick something up? In this chapter we will learn about programming language statements that test the program s current state and choose the next statement to execute based on what they find. One form of this capability is the if statement: If something is true, then execute a group of statements. If it is not true, then skip the group of statements. Another form of this capability is the while statement: while something is true, execute a group of statements. BIT 115: Introduction To Programming 13

14 Two Kinds of Decisions So far, our programs have been composed of a sequence of statements executed in order. The if and while statements are different. As the program is running, they can ask a question. Based on the answer, they choose the next statement or group of statements to execute. In a robot program, the question asked might be, Is the robot s front blocked by a wall? or Is there something on this intersection the robot can pick up? All of these questions have yes or no answers. In fact, if and while statements can only ask yes and no questions. Java uses the keyword true for yes and falsefor no. These keywords represent Boolean values, just like the numbers 0 and 23 represent integer values. George Boole (2 November December 1864) was an English-born mathematician, philosopher and logician. His work was in the fields of differential equations and algebraic logic, and he is now best known as the author of The Laws of Thought. As the inventor of the prototype of what is now called Boolean logic, which became the basis of the modern digital computer, Boole is regarded in hindsight as a founder of the field of computer science. 14

15 If and While When the simplest form of an if statement asks a question and the answer is true, it executes a group of statements once and then continues with the rest of the program. If the answer to the question is false, that group of statements is not executed. When a while statement asks a question and the answer is true, it executes a group of statements (just like the if statement). However, instead of continuing down to the rest of the program, the while statement asks the question again. If the answer is still true, that same group of statements is executed again. This continues until the answer to the question is false. The if statement s question is Should I execute these statements at least once? if (test statement) { // list of statements } The while statement s question is Should I execute these statements again? while (test statement) { // list of statements } 15

16 If: Once or not at all Example: If Statement ASKS THE QUESTION: Should this statement or group of statements be executed once or not at all? Once MsRobotoIf.java Not At All 16

17 Example: While Statement While: Loop as long as true ASKS THE QUESTION: Should this statement or group of statements be executed again? Yes MsRobotWhile.java No 17

18 BIT 115: Introduction To Programming 18

19 Built-In Queries, Predicates The Robot class has several built-in queries that answer questions like Can I pick a Thing up from this Intersection? boolean canpickthing() How many Things are in my backpack? int countthingsinbackpack() What am I called (what string of characters is labeling me)? String getlabel() What Avenue am I on? int getavenue() What is my speed? int getspeed() What Street am I on? int getstreet() Questions with Boolean True or False answers, like canpickthing, are called predicates. Negating a predicate gives it the opposite meaning. BIT 115: Introduction To Programming 19

20 Logical Negation Operator The Robot class does not provide a predicate for testing if the Robot cannot pick up a Thing. Fortunately, any Boolean expression may be negated, or given the opposite value, by using the logical negation operator!. In English, this is usually written and pronounced as not.! means not Logical Negation Operator 20

21 Testing Integer Queries The if and while statements always ask True or Falsequestions. Should I execute the code, true or false? This approach works well for queries that return a boolean value, but how can we use queries that return integers? We do it with comparison operators BIT 115: Introduction To Programming 21

22 Using Comparison Operators: A Few Snippets of Code while(bob.countthingsinbackpack() > 0) // What does this do? { bob.puthing(); bob.move(); } if(bob.getdirection() == Direction.WEST) // What does this do? { bob.turnleft(); bob.turnleft(); } while(bob.getdirection()!= Direction.NORTH) // What does this do? { bob.turnleft(); } 22

23 Two-Sided Queries The examples in the comparison operator table show an integer on only one side, but Java is more flexible than this: it can have a query on both sides of the operator, as in the following statements -- This test determines whether karel is on the diagonal line of intersections (0,0), (1,1), (2,2), and so on. It also includes intersections with negative numbers such as (-3, -3). The following code tests whether the robot s Avenue is five more than the Street. Locations where this tests true include (0,5) and (1,6). BIT 115: Introduction To Programming 23

24 The If-Else Statement The if statement performs an action once or not at all. Another version of the if statement, the if-else statement, choose between two groups of actions. It performs one or it performs the other based on a test. Unlike the if statement, the if-else statement always performs an action. The question is, which action? The general form of the if-else is as follows: MsRobotoIfElse.java MsRobotoWhileIfElse.java MsRobotoWhileifNot.java 24

25 A Brief Introduction: Variables and Parameters 25

26 Brief Intro: Variables & Parameters PLEASE NOTE: We will be going over Variables & Parameters again in more detail in several upcoming Lectures. This is just a teaser or "taste" of things to come A variable is a piece of data like a number that can be changed programmatically (it doesn't have to be the same number over and over again, it isn't constant or set in stone). In other words, a variable can start out one number, like a 0, and be changed by the program into another number, like a 1 or a 2 or a 3, etcetera. 26

27 Brief Intro: Variables & Parameters PLEASE NOTE: We will be going over Variables & Parameters again in more detail in several upcoming Lectures. This is just a teaser or "taste" of things to come When we set up a variable it is called declaring the variable. This declaration consists of three parts: The type of data the variable will hold The name of the variable The initial value the variable starts with In programming, the type of data is called data type and can be a whole number (integer or int for short), a number that can contain a decimal point (float), a true or false value (boolean), or even a single character (char). The name of the variable can be anything you want, but by convention it must start with an alphabetical character (never a number) although could also start with an underscore _ or a dollar sign $. It can contain numbers, but again, never at the beginning. In programming, when you give a variable a starting value or initial value this is called initialization. Before you can use a variable, it must first be initialized. 27

28 Brief Intro: Variables & Parameters PLEASE NOTE: We will be going over Parameters & Variables again in more detail in several upcoming Lectures. This is just a teaser or "taste" of things to come A parameter is a variable that you pass into a method (function) when calling it in main. Jo.moveExactly(12); If you think back to math class, you spend a lot of time talking about f(x). In that case, 'f' is the function, 'x' is the variable, and the passing of 'x' inside the function's parentheses is the parameter. In other words, something passed to 'x' is going to change what the output of 'f' gives you. Being a variable, 'x' is a placeholder for any number that might be passed to the parameter. 28

29 Brief Intro: Variables & Parameters Here is an abstract representation of what is going on. 'x' is a variable because it is a placeholder for any number Inside the function f's parentheses, 'x' represents a parameter, because the value of 'x' is going to be passed into the function, and then something is going to be done with it in some way. If 'x' is a 2, then the output of 'f' is 14 If 'x' is a 3, then the output of 'f' is 19 If 'x' is a 4, then the output of 'f' is 26 If 'x' is a 5, then the output of 'f' is 35 If 'x' is a 6, then the output of 'f' is 46 29

30 Brief Intro: Variables & Parameters Passing a value from the method call in main to the method itself. public void dropthingandmove(int num) { while(this.getavenue() < num) { this.putthing(); this.move(); } } Jo.dropThingAndMove(10); But, how does this work with Java? Let's take a look at some example code! movetest.java movetest2.java - NumTest.java 30

31 4 NOTE: Starting with today's lecture, I will start posting some "Solutions" for the ICEs a day or two after the current lecture on the website 31

Today. Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator

Today. Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator Today Homework 1 / Test 1 Making decisions in Java If statements If/Else ( Either-or ) statements Logical NOT operator BIT 115: Introduction To Programming 1 Something to Remember: In parameter order,

More information

BIT 115: Introduction To Programming LECTURE 3. Instructor: Craig Duckett

BIT 115: Introduction To Programming LECTURE 3. Instructor: Craig Duckett BIT 115: Introduction To Programming LECTURE 3 Instructor: Craig Duckett cduckett@cascadia.edu Lecture 3 Announcements By now everyone should be up and running with Java, jgrasp, and the Becker Robots

More information

Lecture 6. Instructor: Craig Duckett

Lecture 6. Instructor: Craig Duckett Lecture 6 Instructor: Craig Duckett Assignment 1, 2, and A1 Revision Assignment 1 I have finished correcting and have already returned the Assignment 1 submissions. If you did not submit an Assignment

More information

Lecture 12. Instructor: Craig Duckett

Lecture 12. Instructor: Craig Duckett Lecture 12 Instructor: Craig Duckett Assignment 2 Revision DUE TONIGHT! Uploaded to StudentTracker by midnight YOUR LAST CHANCE TO EARN POINTS! Assignment 3 Maze DUE Lecture 13 Uploaded to StudentTracker

More information

Asking For Help. BIT 115: Introduction To Programming 1

Asking For Help. BIT 115: Introduction To Programming 1 Asking For Help Start homeworks As Soon As Possible You may post homework questions to Canvas: Please do not cut and paste entire lines of code, but rather ask conceptual questions. You may also ask me

More information

Lecture 10. Instructor: Craig Duckett

Lecture 10. Instructor: Craig Duckett Lecture 10 Instructor: Craig Duckett Announcements Assignment 1 Revision DUE TONIGHT in StudentTracker by midnight If you have not yet submitted an Assignment 1, this is your last chance to do so to earn

More information

Lecture 8 " INPUT " Instructor: Craig Duckett

Lecture 8  INPUT  Instructor: Craig Duckett Lecture 8 " INPUT " Instructor: Craig Duckett Assignments Assignment 2 Due TONIGHT Lecture 8 Assignment 1 Revision due Lecture 10 Assignment 2 Revision Due Lecture 12 We'll Have a closer look at Assignment

More information

Lecture 7. Instructor: Craig Duckett OUTPUT

Lecture 7. Instructor: Craig Duckett OUTPUT Lecture 7 Instructor: Craig Duckett OUTPUT Lecture 7 Announcements ASSIGNMENT 2 is due LECTURE 8 NEXT LECTURE uploaded to StudentTracker by midnight Assignment 2!!! Assignment Dates (By Due Date) Assignment

More information

ASSIGNMENT 4 Classes and Objects

ASSIGNMENT 4 Classes and Objects ASSIGNMENT 4 Classes and Objects COMP-202A, Fall 2010, All Sections Due: Friday, November 19, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all

More information

Lecture 13. Instructor: Craig Duckett. Boolean Expressions, Logical Operators, and Return Values

Lecture 13. Instructor: Craig Duckett. Boolean Expressions, Logical Operators, and Return Values Lecture 13 Instructor: Craig Duckett Boolean Expressions, Logical Operators, and Return Values Assignment 3: The Maze DUE TONIGHT! Uploaded to StudentTracker by midnight If you are submitting as part of

More information

Lecture 11. Instructor: Craig Duckett. Instance Variables

Lecture 11. Instructor: Craig Duckett. Instance Variables Lecture 11 Instructor: Craig Duckett Instance Variables Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section 1: Wednesday,

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

Combo Lecture Lecture 14/15. Instructor: Craig Duckett

Combo Lecture Lecture 14/15. Instructor: Craig Duckett Combo Lecture Lecture 14/15 Instructor: Craig Duckett Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section 1: Wednesday,

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

Robots. Byron Weber Becker. chapter 6

Robots. Byron Weber Becker. chapter 6 Using Variables Robots Learning to Program with Java Byron Weber Becker chapter 6 Announcements (Oct 3) Reminder: Reading for today y( (Oct 3 rd ) Ch 6.1-6.4 Reading for Wednesday (Oct 3 rd ) The rest

More information

Lecture 17. Instructor: Craig Duckett. Passing & Returning Arrays

Lecture 17. Instructor: Craig Duckett. Passing & Returning Arrays Lecture 17 Instructor: Craig Duckett Passing & Returning Arrays Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section

More information

ASSIGNMENT 3 Classes, Objects and the Robot World

ASSIGNMENT 3 Classes, Objects and the Robot World ASSIGNMENT 3 Classes, Objects and the Robot World COMP-202B, Winter 2009, All Sections Due: Tuesday, March 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information

Lecture 8. A series on variable types This episode starring Parameter Variables

Lecture 8. A series on variable types This episode starring Parameter Variables Lecture 8 A series on variable types This episode starring Parameter Variables Declaring an Integer Variable Variable Types Variable Type How it is defined Scope (how long it lasts) Uses Local Variable

More information

Lecture 2 Announcements

Lecture 2 Announcements Lecture 2 Announcements Home Computers and/or Laptops/Notebooks By now you should have installed Java SE 8 and jgrasp on your computers, set up the becker.jar file, and started working with some of the

More information

SSEA Computer Science: Track A. Dr. Cynthia Lee Lecturer in Computer Science Stanford

SSEA Computer Science: Track A. Dr. Cynthia Lee Lecturer in Computer Science Stanford SSEA Computer Science: Track A Dr. Cynthia Lee Lecturer in Computer Science Stanford Topics for today Introduce Java programming language Assignment and type casting Expressions Operator precedence Code

More information

Variables and Classes. In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming

Variables and Classes. In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming Variables and Classes In which we over-ride the super class, work with multiple classes, and move towards non-robot based programming Classes Class extends Class attributes:

More information

ASSIGNMENT 4 Records and Objects

ASSIGNMENT 4 Records and Objects ASSIGNMENT 4 Records and Objects COMP-202B, Winter 2010, All Sections Due: Wednesday, March 31, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all

More information

Physics 2660: Fundamentals of Scientific Computing. Lecture 5 Instructor: Prof. Chris Neu

Physics 2660: Fundamentals of Scientific Computing. Lecture 5 Instructor: Prof. Chris Neu Physics 2660: Fundamentals of Scientific Computing Lecture 5 Instructor: Prof. Chris Neu (chris.neu@virginia.edu) Reminder I am back! HW04 due Thursday 22 Feb electronically by noon HW grades are coming.

More information

CSE 113 A. Announcements - Lab

CSE 113 A. Announcements - Lab CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure

More information

Programming Lecture 3

Programming Lecture 3 Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements

More information

Introduction to Java

Introduction to Java Introduction to Java A Farewell to Karel Welcome to Java But First... A Brief History of Digital Computers Image credit: http://upload.wikimedia.org/wikipedia/commons/4/4e/eniac.jpg Programming in the

More information

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th COMS 1003 Fall 2005 Introduction to Computer Programming in C Bits, Boolean Logic & Discrete Math September 13 th Hello World! Logistics See the website: http://www.cs.columbia.edu/~locasto/ Course Web

More information

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1 topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is

More information

Programming in Karel. Eric Roberts and Jerry Cain CS 106J April 5, 2017

Programming in Karel. Eric Roberts and Jerry Cain CS 106J April 5, 2017 Programming in Karel Eric Roberts and Jerry Cain CS 106J April 5, 2017 Once upon a time... Rich Pattis and Karel the Robot Karel the Robot was developed by Rich Pattis in the 1970s when he was a graduate

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression Outline ECS 10 10/8 Announcements Homework 2 questions Boolean expressions If/else statements State variables and avoiding sys.exit( ) Example: Coin flipping (if time permits) Announcements Professor Amenta

More information

Topic 4 Expressions and variables

Topic 4 Expressions and variables Topic 4 Expressions and variables "Once a person has understood the way variables are used in programming, he has understood the quintessence of programming." -Professor Edsger W. Dijkstra Based on slides

More information

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5 [talking head] Formal Methods of Software Engineering means the use of mathematics as an aid to writing programs. Before we can

More information

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017 Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful

More information

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5 C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................

More information

Math-2. Lesson 3-1. Equations of Lines

Math-2. Lesson 3-1. Equations of Lines Math-2 Lesson 3-1 Equations of Lines How can an equation make a line? y = x + 1 x -4-3 -2-1 0 1 2 3 Fill in the rest of the table rule x + 1 f(x) -4 + 1-3 -3 + 1-2 -2 + 1-1 -1 + 1 0 0 + 1 1 1 + 1 2 2 +

More information

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)... Remembering numbers (and other stuff)... Let s talk about one of the most important things in any programming language. It s called a variable. Don t let the name scare you. What it does is really simple.

More information

We know have to navigate between Karel s World view, Karel s Program view and Karel s Execution (or Run) view.

We know have to navigate between Karel s World view, Karel s Program view and Karel s Execution (or Run) view. We know how to write programs using Karel s primitive commands move turnleft pickbeeper putbeeper turnoff We know have to navigate between Karel s World view, Karel s Program view and Karel s Execution

More information

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types. Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #44. Multidimensional Array and pointers

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #44. Multidimensional Array and pointers Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #44 Multidimensional Array and pointers In this video, we will look at the relation between Multi-dimensional

More information

CS112 Lecture: Introduction to Karel J. Robot

CS112 Lecture: Introduction to Karel J. Robot CS112 Lecture: Introduction to Karel J. Robot Last revised 1/17/08 Objectives: 1. To introduce Karel J. Robot as an example of an object-oriented system. 2. To explain the mechanics of writing simple Karel

More information

COMP 202 Java in one week

COMP 202 Java in one week COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110. Lecture 2 Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

More information

CMSC 201 Computer Science I for Majors

CMSC 201 Computer Science I for Majors CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset

More information

Variables and Data Representation

Variables and Data Representation You will recall that a computer program is a set of instructions that tell a computer how to transform a given set of input into a specific output. Any program, procedural, event driven or object oriented

More information

Math 2280: Introduction to Differential Equations- Syllabus

Math 2280: Introduction to Differential Equations- Syllabus Math 2280: Introduction to Differential Equations- Syllabus University of Utah Spring 2013 1 Basic Information Instructor - Patrick Dylan Zwick Email - zwick@math.utah.edu Phone - 801-651-8768 Office Hour

More information

ENGR 101 Engineering Design Workshop

ENGR 101 Engineering Design Workshop ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as

More information

Computational Expression

Computational Expression Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name

More information

MICROPROCESSORS A (17.383) Fall Lecture Outline

MICROPROCESSORS A (17.383) Fall Lecture Outline MICROPROCESSORS A (17.383) Fall 2010 Lecture Outline Class # 03 September 21, 2010 Dohn Bowden 1 Today s Lecture Syllabus review Microcontroller Hardware and/or Interface Programming/Software Lab Homework

More information

COMP combinational logic 1 Jan. 18, 2016

COMP combinational logic 1 Jan. 18, 2016 In lectures 1 and 2, we looked at representations of numbers. For the case of integers, we saw that we could perform addition of two numbers using a binary representation and using the same algorithm that

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

StudyHub+ 1. StudyHub: AP Java. Semester One Final Review

StudyHub+ 1. StudyHub: AP Java. Semester One Final Review StudyHub+ 1 StudyHub: AP Java Semester One Final Review StudyHub+ 2 Terminology: Primitive Data Type: Most basic data types in the Java language. The eight primitive data types are: Char: A single character

More information

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Your Instructor Your instructor: Ziad Matni, Ph.D(zee-ahd

More information

Genome Sciences 373: Genome Informatics. Quiz section #1 March 29, 2018

Genome Sciences 373: Genome Informatics. Quiz section #1 March 29, 2018 Genome Sciences 373: Genome Informatics Quiz section #1 March 29, 2018 About me Email: hpliner@uw.edu Office hours: Thursday right after quiz section (2:20pm) Foege S110 Or by appointment Other help: I

More information

SSEA Computer Science: CS106A. Dr. Cynthia Lee Lecturer in Computer Science Stanford

SSEA Computer Science: CS106A. Dr. Cynthia Lee Lecturer in Computer Science Stanford SSEA Computer Science: CS106A Dr. Cynthia Lee Lecturer in Computer Science Stanford Topics for today Learn how to harness computing power to solve problems. To that end: Introduce Java programming language

More information

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout

More information

CS 106A, Lecture 5 Booleans and Control Flow

CS 106A, Lecture 5 Booleans and Control Flow CS 106A, Lecture 5 Booleans and Control Flow suggested reading: Java Ch. 3.4-4.6 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons Attribution 2.5

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual: Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

More information

Decisions, Decisions. Testing, testing C H A P T E R 7

Decisions, Decisions. Testing, testing C H A P T E R 7 C H A P T E R 7 In the first few chapters, we saw some of the basic building blocks of a program. We can now make a program with input, processing, and output. We can even make our input and output a little

More information

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

Coding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic.

Coding Workshop. Learning to Program with an Arduino. Lecture Notes. Programming Introduction Values Assignment Arithmetic. Coding Workshop Learning to Program with an Arduino Lecture Notes Table of Contents Programming ntroduction Values Assignment Arithmetic Control Tests f Blocks For Blocks Functions Arduino Main Functions

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #06 Loops: Operators Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #06 Loops: Operators We have seen comparison operators, like less then, equal to, less than or equal. to and

More information

CS112 Lecture: Working with Numbers

CS112 Lecture: Working with Numbers CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations

More information

Robots. Byron Weber Becker. chapter 6

Robots. Byron Weber Becker. chapter 6 Using Variables Robots Learning to Program with Java Byron Weber Becker chapter 6 Announcements (Oct 5) Chapter 6 You don t have to spend much time on graphics in Ch6 Just grasp the concept Reminder: Reading

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Announcements. 1. Forms to return today after class:

Announcements. 1. Forms to return today after class: Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.

More information

Assignment #1: /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th

Assignment #1:  /Survey and Karel the Robot Karel problems due: 1:30pm on Friday, October 7th Mehran Sahami Handout #7 CS 06A September 8, 06 Assignment #: Email/Survey and Karel the Robot Karel problems due: :0pm on Friday, October 7th Email and online survey due: :9pm on Sunday, October 9th Part

More information

1 Making Decisions in Arduino Programs

1 Making Decisions in Arduino Programs ME 120: If-then-else structures in Arduino October 11, 2018 Gerald Recktenwald gerry@pdx.edu 1 Making Decisions in Arduino Programs It s incredibly useful that computer programs can respond to changing

More information

CS 360: Programming Languages Lecture 10: Introduction to Haskell

CS 360: Programming Languages Lecture 10: Introduction to Haskell CS 360: Programming Languages Lecture 10: Introduction to Haskell Geoffrey Mainland Drexel University Thursday, February 5, 2015 Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia

More information

Activity Boolean Algebra

Activity Boolean Algebra Activity 2.1.6 Boolean Algebra Introduction Have you ever had an idea that you thought was so unique that when you told someone else about it, you simply could not believe they thought you were wasting

More information

Mehran Sahami Handout #7 CS 106A September 24, 2014

Mehran Sahami Handout #7 CS 106A September 24, 2014 Mehran Sahami Handout #7 CS 06A September, 0 Assignment #: Email/Survey and Karel the Robot Karel problems due: :pm on Friday, October rd Email and online survey due: :9pm on Sunday, October th Part I

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Administrative This class is currently FULL and

More information

CSC-140 Assignment 6

CSC-140 Assignment 6 CSC-140 Assignment 6 1 Introduction In this assignment we will start out defining our own classes. For now, we will design a class that represents a date, e.g., Tuesday, March 15, 2011, or in short hand

More information

Computational Expression

Computational Expression Computational Expression Conditionals Janyl Jumadinova 10 October, 2018 Janyl Jumadinova Computational Expression 10 October, 2018 1 / 16 Computational Thinking: a problem solving process Decomposition

More information

C++ Reference NYU Digital Electronics Lab Fall 2016

C++ Reference NYU Digital Electronics Lab Fall 2016 C++ Reference NYU Digital Electronics Lab Fall 2016 Updated on August 24, 2016 This document outlines important information about the C++ programming language as it relates to NYU s Digital Electronics

More information

Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few

Most of the class will focus on if/else statements and the logical statements (conditionals) that are used to build them. Then I'll go over a few With notes! 1 Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few useful functions (some built into standard

More information

The Java Language Rules And Tools 3

The Java Language Rules And Tools 3 The Java Language Rules And Tools 3 Course Map This module presents the language and syntax rules of the Java programming language. You will learn more about the structure of the Java program, how to insert

More information

Midterms Save the Dates!

Midterms Save the Dates! University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 15 Branching : IF ELSE Statement We are looking

More information

CS112 Lecture: Extending Classes and Defining Methods

CS112 Lecture: Extending Classes and Defining Methods Objectives: CS112 Lecture: Extending Classes and Defining Methods Last revised 1/9/04 1. To introduce the idea of extending existing classes to add new methods 2. To introduce overriding of inherited methods

More information

In Java, data type boolean is used to represent Boolean data. Each boolean constant or variable can contain one of two values: true or false.

In Java, data type boolean is used to represent Boolean data. Each boolean constant or variable can contain one of two values: true or false. CS101, Mock Boolean Conditions, If-Then Boolean Expressions and Conditions The physical order of a program is the order in which the statements are listed. The logical order of a program is the order in

More information

More loops Ch

More loops Ch More loops Ch 3.3-3.4 Announcements Quiz next week! -Covers up to (and including) HW1 (week 1-3) -Topics: cout/cin, types, scope, if/else, etc. Review: Loops We put a loop around code that we want to run

More information

These are notes for the third lecture; if statements and loops.

These are notes for the third lecture; if statements and loops. These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern

More information

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose

More information

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops PRG PROGRAMMING ESSENTIALS 1 Lecture 2 Program flow, Conditionals, Loops https://cw.fel.cvut.cz/wiki/courses/be5b33prg/start Michal Reinštein Czech Technical University in Prague, Faculty of Electrical

More information

Variables and Functions. ROBOTC Software

Variables and Functions. ROBOTC Software Variables and Functions ROBOTC Software Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal numbers, and words Variable names follow the same

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Programming Karel the Robot

Programming Karel the Robot Programming Karel the Robot Announcements Five Handouts Today: Honor Code Downloading Eclipse Running Karel Programs in Eclipse Programming Assignment #1 Submitting Programming Assignments Please only

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage:

Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi Section Webpage: Discussion 1H Notes (Week 2, 4/8) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 Variables You have to instruct your computer every little thing it needs to do even

More information

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users Introduction to PHP Let's Look Back We talked about how to create a form in HTML Forms are one way to interact with users Users can enter information into forms which can be used by you (programmer) We

More information