CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG

Size: px
Start display at page:

Download "CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG"

Transcription

1 CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG 1

2 Notice Assignments No new homework this week. Please make up the homework 1 5 & class exercises this week. 2

3 Notice: Mid-Term Mid-term Exam Date: the class on October 27 th (11:00 AM 12:15 PM) It covers the knowledge from Class 1 to Class 12 (October 13) Open-book but no electronic devices allowed You will be expected to read and write short segments of code Prepare Mid-term Exam Review class notes & class quizzes: 1 12 Weekly quizzes: 1 5 Homework: 2-5 Mid-term Review is posted here Mid-term Practice is posted here TA will go through the Mid-term Practice on October 20 th 3

4 New Materials Outline Object Equality Multiple Conditions Cumulative Sum Min/Max Loops Cumulative Sum with if 4

5 Object Equality You can't use the equality relational operator, ==, with objects Primitive types have only one value... but objects can have many values inside them... so deciding when one object equals another... is not an easy thing to do If you try to use the equality operator, ==... on objects... you will get a logic error 5

6 Object Equality 6

7 Object Equality We need a different way of testing for equality when dealing with objects Every Java object must have an equals method It is this method we should use... when testing for equality between objects The String method provides an equals method We have to use this method when comparing strings 7

8 Object Equality 8

9 New Materials Outline Object Equality Multiple Conditions Cumulative Sum Min/Max Loops Cumulative Sum with if 9

10 Multiple Conditions Sometimes when writing an if statement... you need to test for more than one condition Suppose you wanted to check that a number input by a user... is between 1 and 5 You could so something like this if (number >= 1){ if (number <= 5) { processnumber(number); } } 10

11 Multiple Conditions But Java gives you an alternative You can combine the two tests by using the logical AND operator The logical AND operator evaluates to true... if both of the expressions it operates upon are true Otherwise, it evaluates to false In Java, the symbol for the logical AND operator is two ampersands, && Using the logical AND operator we can rewrite this code as follows if (number >= 1 && number <= 5){ processnumber(number); } 11

12 Multiple Conditions There is also a logical OR operator The logical OR operator evaluates to true... if either of of its two operands is true In Java, the symbol for the logical OR operator... is two vertical bars, Again, there can't be any spaces between them So if we wanted to test whether a number is 1 or 2, we could write if (number == 1 number == 2){ processnumber(number); } 12

13 New Materials Outline Object Equality Multiple Conditions Cumulative Sum Min/Max Loops Cumulative Sum with if 13

14 Cumulative Sum We often need to compute the sum of a list of numbers The best way to do this is to keep a running total You declare variable to hold the sum and initialize it to 0 Then work your way through the list of numbers... adding each one, in turn to this running total Here is the pseudocode for this approach sum = 0 for (all numbers) { obtain next number sum += next } 14

15 Cumulative Sum To turn this algorithm into code... you need to know how many numbers to expect Let's look at a program which prompts the user... for the number of values to be entered... and then asks for the the values themselves 15

16 Cumulative Sum Notice that we declared the variable sum outside the loop We need to initialize sum to 0.0 With each pass through the loop... we add the next number to sum 16

17 New Materials Outline Object Equality Multiple Conditions Cumulative Sum Min/Max Loops Cumulative Sum with if 17

18 Min/Max Loops Another common programming problem is to find the maximum or minimum of a list of numbers Here's what we need to do to find a maximum Define a variable to hold the current maximum value Set this variable to an initial value For each value in the list, compare the new value to the current maximum... if the current value is larger then the current maximum... make this new value the current maximum 18

19 Min/Max Loops Here's what it looks like in pseudocode initialize max for (all numbers) { obtain next if (next > max) { max = next } } But what should we use for the initial value... of the variable that will hold the current maximum value? 19

20 Min/Max Loops We can't use zero If we did, we would get the wrong result for the following series of numbers: -87, -101, -35, -42, -200, -50 All of these numbers are less than 0... so the result would be 0... which is the wrong answer 20

21 Min/Max Loops There are two ways to deal with this problem If we knew the range of values to expect... We could set the initial value... to the lowest possible number in this range We need to use the lowest possible number... so that this initial value will be replaced... by one of the numbers in the series The second approach is to use the first values entered... to set the initial value of the maximum This is a little inconvenient... because it means reading the first value outside the loop 21

22 Min/Max Loops The pseudocode that covers these two possibilities is initialize max either to lowest possible value or to first value for (all numbers) { obtain next if (next > max) { max = next; } } 22

23 New Materials Outline Object Equality Multiple Conditions Cumulative Sum Min/Max Loops Cumulative Sum with if 23

24 Cumulative Sum with if Whenever we take the average of a series of numbers, we Add all the number together Divide the total by the number of values in the series So the code would look something like this The variable numberofnumbers... contains the length of the list of numbers we are averaging There is a problem with this code What happens if numberofnumbers is 0? 24

25 Cumulative Sum with if 25

26 Cumulative Sum with if NaN stands for Not A Number... because division by zero is not defined So we need to test for zero... before trying to determine the average 26

27 Cumulative Sum with if You can also use an if statement... to count how many negative numbers are entered We can do this by using a counter A counter is a variable that keeps track... of the number of times something has happened We need to initialize the counter to 0... and use an if statement to increment the counter... each time we encounter a negative number 27

28 Cumulative Sum with if 28

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 9 Exercise

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 8: SEP. 29TH INSTRUCTOR: JIAYIN WANG 1 Notice Prepare the Weekly Quiz The weekly quiz is for the knowledge we learned in the previous week (both the

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 19: NOV. 15TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 19: NOV. 15TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 19: NOV. 15TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignment Class Exercise 19 is assigned Homework 8 is assigned Both Homework 8 and Exercise 19 are

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 10 Exercise

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18 Assignment Lecture 9 Logical Operations Formatted Print Printf Increment and decrement Read through 3.9, 3.10 Read 4.1. 4.2, 4.3 Go through checkpoint exercise 4.1 Logical Operations - Motivation Logical

More information

Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java

Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java Use BigDecimal (a class defined in package java.math) to write

More information

(6-1) Iteration in C H&K Chapter 5. Instructor - Andrew S. O Fallon CptS 121 (February 11, 2019) Washington State University

(6-1) Iteration in C H&K Chapter 5. Instructor - Andrew S. O Fallon CptS 121 (February 11, 2019) Washington State University (6-1) Iteration in C H&K Chapter 5 Instructor - Andrew S. O Fallon CptS 121 (February 11, 2019) Washington State University Iterative Constructs (1) 2 Recall that algorithms are composed of three different

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 31 / 2014 Instructor: Michael Eckmann Today s Topics Comments and/or Questions? Pseudocode Programming exercise to determine projected homeruns How Java determines

More information

Functions 3.6. Fall Math (Math 1010) M / 13

Functions 3.6. Fall Math (Math 1010) M / 13 Functions 3.6 Fall 2013 - Math 1010 (Math 1010) M 1010 3.6 1 / 13 Roadmap 3.6 - Functions: Relations, Functions 3.6 - Evaluating Functions, Finding Domains and Ranges (Math 1010) M 1010 3.6 2 / 13 3.6

More information

ECE 156A - Syllabus. Description

ECE 156A - Syllabus. Description ECE 156A - Syllabus Lecture 0 ECE 156A 1 Description Introduction to HDL (Hardware Description Language) basic elements, HDL simulation concepts, HDL concurrent statements with examples and applications,

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: if Single-Selection Statement CSC 209 JAVA I. week 3- Control Statements: Part I AL GHURAIR UNIVERSITY College of Computing CSC 209 JAVA I week 3- Control Statements: Part I Objectives: To use the if and if...else selection statements to choose among alternative actions. To use the

More information

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include 1 Programming in C Looping Subtasks We will examine some basic algorithms that use the while and if constructs. These subtasks include Reading unknown quantity of data Counting things Accumulating (summing)

More information

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014 CMPSCI 250: Introduction to Computation Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014 Things, Sets, and Strings The Mathematical Method Administrative Stuff The Objects of Mathematics

More information

Operators & Expressions

Operators & Expressions Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.

More information

Fundamentals of Programming Session 7

Fundamentals of Programming Session 7 Fundamentals of Programming Session 7 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

Reviewing all Topics this term

Reviewing all Topics this term Today in CS161 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for) Functions (pass by value, pass by reference) Arrays (specifically arrays of characters)

More information

WYSE Academic Challenge 2017 Software Changes

WYSE Academic Challenge 2017 Software Changes WYSE Academic Challenge 2017 Software Changes This document outlines the means by which site coordinators can gain access to the WYSE Academic Challenge 2017 online software. In the past, the online software

More information

CPS 110 Final Exam. Spring 2011

CPS 110 Final Exam. Spring 2011 CPS 110 Final Exam Spring 2011 Please answer all questions for a total of 300 points. Keep it clear and concise: answers are graded on content, not style. I expect that you can answer each question within

More information

TOPIC 8 MORE ON WHILE LOOPS

TOPIC 8 MORE ON WHILE LOOPS 1 TOPIC 8 MORE ON WHILE LOOPS Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared by B. Ericson.

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Rules of Exponents Part 1[Algebra 1](In Class Version).notebook. August 22, 2017 WARM UP. Simplify using order of operations. SOLUTION.

Rules of Exponents Part 1[Algebra 1](In Class Version).notebook. August 22, 2017 WARM UP. Simplify using order of operations. SOLUTION. WARM UP Simplify using order of operations. Aug 22 3:22 PM 1 Aug 22 4:09 PM 2 WARM UP a) The equation 3(4x) = (4x)3 illustrates which property? b) Which property of real numbers is illustrated by the equation

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

Stepwise Refinement. Lecture 12 COP 3014 Spring February 2, 2017

Stepwise Refinement. Lecture 12 COP 3014 Spring February 2, 2017 Stepwise Refinement Lecture 12 COP 3014 Spring 2017 February 2, 2017 Top-Down Stepwise Refinement Top down stepwise refinement is a useful problem-solving technique that is good for coming up with an algorithm.

More information

Data Types primitive, arrays, objects Java overview Primitive data types in Java

Data Types primitive, arrays, objects Java overview Primitive data types in Java Data Types primitive, arrays, objects Java overview Primitive data types in Java 46 Recap Day 2! Lessons Learned:! Sample run vs. pseudocode! Java program structure: set-up, then real statements, decent

More information

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003 Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an

More information

Introduction to Sets and Logic (MATH 1190)

Introduction to Sets and Logic (MATH 1190) Introduction to Sets and Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics and Statistics York University Dec 4, 2014 Outline 1 2 3 4 Definition A relation R from a set A to a set

More information

(Refer Slide Time: 00:26)

(Refer Slide Time: 00:26) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute Technology, Madras Module 07 Lecture 07 Contents Repetitive statements

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

Over and Over Again GEEN163

Over and Over Again GEEN163 Over and Over Again GEEN163 There is no harm in repeating a good thing. Plato Homework A programming assignment has been posted on Blackboard You have to convert three flowcharts into programs Upload the

More information

Simplifying Square Root Expressions[In Class Version][Algebra 1 Honors].notebook August 26, Homework Assignment. Example 5 Example 6.

Simplifying Square Root Expressions[In Class Version][Algebra 1 Honors].notebook August 26, Homework Assignment. Example 5 Example 6. Homework Assignment The following examples have to be copied for next class Example 1 Example 2 Example 3 Example 4 Example 5 Example 6 Example 7 Example 8 Example 9 Example 10 Example 11 Example 12 The

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : PROGRAMMING LOGIC AND DESIGN COURSE CODE : CCIS1003 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

CS 135 Lab Assignments Week 1

CS 135 Lab Assignments Week 1 CS 135 Lab Assignments Week 1 Professor: Matt B. Pedersen This handout is the assignment that you must finish for the lab portion of the course in week 1. You must finish the assignments yourself; if you

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

CS110D: PROGRAMMING LANGUAGE I

CS110D: PROGRAMMING LANGUAGE I CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need

More information

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00

More information

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming

Arrays: Higher Dimensional Arrays. CS0007: Introduction to Computer Programming Arrays: Higher Dimensional Arrays CS0007: Introduction to Computer Programming Review If the == operator has two array variable operands, what is being compared? The reference variables held in the variables.

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information

CS 117 Fall Compound boolean expressions. Control Statements, Part 2. Using boolean operators. Boolean operators

CS 117 Fall Compound boolean expressions. Control Statements, Part 2. Using boolean operators. Boolean operators CS 117 Fall 2003 Control Statements, Part 2 Compound boolean expressions Sometimes we want to evaluate more complex expressions if age is greater than 30 but less than 65, print out You are an old geezer

More information

Algebraically Speaking Chalkdust Algebra 1 Fall Semester

Algebraically Speaking Chalkdust Algebra 1 Fall Semester Algebraically Speaking Chalkdust Algebra 1 Fall Semester Homework Assignments: Chapter 1 The Real Number System: Lesson 1.1 - Real Numbers: Order and Absolute Value Do the following problems: # 1 9 Odd,

More information

Chapter 3. Iteration

Chapter 3. Iteration Chapter 3 Iteration Iteration Iteration is the form of program control that allows us to repeat a section of code. For this reason this form of control is often also referred to as repetition. The programming

More information

CSC 111 Introduction to Computer Science (Section C)

CSC 111 Introduction to Computer Science (Section C) CSC 111 Introduction to Computer Science (Section C) Course Description: (4h) Lecture and laboratory. Rigorous introduction to the process of algorithmic problem solving and programming in a modern programming

More information

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015 Name: USC netid (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015 There are 5 problems on the exam, with 58 points total available. There are 10 pages to the exam (5 pages

More information

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1

Lecture 9. Monday, January 31 CS 205 Programming for the Sciences - Lecture 9 1 Lecture 9 Reminder: Programming Assignment 3 is due Wednesday by 4:30pm. Exam 1 is on Friday. Exactly like Prog. Assign. 2; no collaboration or help from the instructor. Log into Windows/ACENET. Start

More information

1. Textbook #1: Our Digital World (ODW). 2. Textbook #2: Guidelines for Office 2013 (GFO). 3. SNAP: Assessment Software

1. Textbook #1: Our Digital World (ODW). 2. Textbook #2: Guidelines for Office 2013 (GFO). 3. SNAP: Assessment Software CIS - Survey of Computer Information Systems FALL 014-16-Week Course Professor: JON P. RAGER Weekly Schedule Note: This schedule is subjected to BE CHANGED at your instructor's discretion. Please check

More information

You must pass the final exam to pass the course.

You must pass the final exam to pass the course. Computer Science Technology Department Houston Community College System Department Website: http://csci.hccs.cc.tx.us CRN: 46876 978-1-4239-0146-4 1-4239-0146-0 Semester: Fall 2010 Campus and Room: Stafford

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

COSC 115: Introduction to Web Authoring Fall 2013

COSC 115: Introduction to Web Authoring Fall 2013 COSC 115: Introduction to Web Authoring Fall 2013 Instructor: David. A. Sykes Class meetings: TR 1:00 2:20PM, Olin 212 Office / Hours: Olin 204E / TR 8:00-10:20AM, MWF 1:00 3:00PM, or by appointment/happenstance

More information

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency. Description of CPSC 301: This is a 2-unit credit/no credit course. It is a course taught entirely in lab, and has two required 2-hour 50-minute lab sessions per week. It will review, reinforce, and expand

More information

Problem Solving for Intro to Computer Science

Problem Solving for Intro to Computer Science Problem Solving for Intro to Computer Science The purpose of this document is to review some principles for problem solving that are relevant to Intro to Computer Science course. Introduction: A Sample

More information

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes ) CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16 In-Class Midterm ( 11:35 AM 12:50 PM : 75 Minutes ) This exam will account for either 15% or 30% of your overall grade depending on your

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information: CSE 131 Introduction to Computer Science Fall 2016 Given: 29 September 2016 Exam I Due: End of Exam Session This exam is closed-book, closed-notes, no electronic devices allowed The exception is the "sage

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

ECE573 Introduction to Compilers & Translators

ECE573 Introduction to Compilers & Translators ECE573 Introduction to Compilers & Translators Tentative Syllabus Fall 2005 Tu/Th 9:00-10:15 AM, EE 115 Instructor Prof. R. Eigenmann Tel 49-41741 Email eigenman@ecn Office EE334C Office Hours Tu 10:15-11:30

More information

APPM 2460: Week Three For, While and If s

APPM 2460: Week Three For, While and If s APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop

More information

TEST ACCOMMODATIONS: Process Overview

TEST ACCOMMODATIONS: Process Overview TEST ACCOMMODATIONS: Process Overview NOTIFICATION OF ACCOMMODATIONS Each quarter, Instructor receives a Notification of Accommodations. This notification informs you that a student in your class is approved

More information

CS 61B Data Structures and Programming Methodology. June David Sun

CS 61B Data Structures and Programming Methodology. June David Sun CS 61B Data Structures and Programming Methodology June 25 2008 David Sun Announcements Visit 387 Soda to arrange for after hours access to Soda Hall. Computer Science Undergraduate Association event:

More information

CSc 2310 Principles of Programming (Java) Jyoti Islam

CSc 2310 Principles of Programming (Java) Jyoti Islam CSc 2310 Principles of Programming (Java) Jyoti Islam Are you in the right class??? Check the CRN of your registration Instructor Jyoti Islam PhD Student, concentration: Machine Learning 4+ years of Industry

More information

Laboratory 5: Implementing Loops and Loop Control Strategies

Laboratory 5: Implementing Loops and Loop Control Strategies Laboratory 5: Implementing Loops and Loop Control Strategies Overview: Objectives: C++ has three control structures that are designed exclusively for iteration: the while, for and do statements. In today's

More information

Introduction to Software Development (ISD) David Weston and Igor Razgon

Introduction to Software Development (ISD) David Weston and Igor Razgon Introduction to Software Development (ISD) David Weston and Igor Razgon Autumn term 2013 Course book The primary book supporting the ISD module is: Java for Everyone, by Cay Horstmann, 2nd Edition, Wiley,

More information

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C

More information

Computer Organization & Assembly Language Programming

Computer Organization & Assembly Language Programming Computer Organization & Assembly Language Programming CSE 2312 Lecture 11 Introduction of Assembly Language 1 Assembly Language Translation The Assembly Language layer is implemented by translation rather

More information

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

More on Arrays CS 16: Solving Problems with Computers I Lecture #13 More on Arrays CS 16: Solving Problems with Computers I Lecture #13 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #12 due today No homework assigned today!! Lab #7 is due on Monday,

More information

Linear Algebra Math 203 section 003 Fall 2018

Linear Algebra Math 203 section 003 Fall 2018 Linear Algebra Math 203 section 003 Fall 2018 Mondays and Wednesdays from 7:20 pm to 8:35 pm, in Planetary Hall room 131. Instructor: Dr. Keith Fox Email: kfox@gmu.edu Office: Exploratory Hall Room 4405.

More information

QUIZ Lesson 4. Exercise 4: Write an if statement that assigns the value of x to the variable y if x is in between 1 and 20, otherwise y is unchanged.

QUIZ Lesson 4. Exercise 4: Write an if statement that assigns the value of x to the variable y if x is in between 1 and 20, otherwise y is unchanged. QUIZ Lesson 4 Exercise 4: Write an if statement that assigns the value of x to the variable y if x is in between 1 and 20, otherwise y is unchanged. QUIZ Lesson 4 Exercise 4: Write an if statement that

More information

Database Programming - Section 16. Instructor Guide

Database Programming - Section 16. Instructor Guide Database Programming - Section 16 Instructor Guide Table of Contents...1 Lesson 1 - Final Exam Preparation...1 What Will I Learn?...2 Why Learn It?...3 Tell Me / Show Me...4 Try It / Solve It...5 Lesson

More information

Quiz 1: Functions and Procedures

Quiz 1: Functions and Procedures Quiz 1: Functions and Procedures Outline Basics Control Flow While Loops Expressions and Statements Functions Primitive Data Types 3 simple data types: number, string, boolean Numbers store numerical data

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Prerequisites A seven credit unit course Replaced OHJ-2156 Analysis of Algorithms We take things a bit further than

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 18 Switch Statement (Contd.) And Introduction to

More information

Prelim One Solution. CS211 Fall Name. NetID

Prelim One Solution. CS211 Fall Name. NetID Name NetID Prelim One Solution CS211 Fall 2005 Closed book; closed notes; no calculators. Write your name and netid above. Write your name clearly on each page of this exam. For partial credit, you must

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #3 Loops Part I Contents Introduction For-Loop

More information

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++ Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure

More information

CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science

CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science Semester and Year: Fall 2008 Classroom Section, Meeting Times,

More information

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto CS 170 Java Programming 1 Expressions Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 What is an expression? Expression Vocabulary Any combination of operators and operands which, when

More information

Notes Lesson 3 4. Positive. Coordinate. lines in the plane can be written in standard form. Horizontal

Notes Lesson 3 4. Positive. Coordinate. lines in the plane can be written in standard form. Horizontal A, B, C are Notes Lesson 3 4 Standard Form of an Equation: Integers Ax + By = C Sometimes it is preferred that A is Positive All lines in the plane can be written in standard form. Oblique Coordinate Horizontal

More information

SaM. 1. Introduction. 2. Stack Machine

SaM. 1. Introduction. 2. Stack Machine SaM 1. Introduction Have you ever heard the Java mantra, write once, run everywhere? So, how does that work? When you compile a Java program, you generate a binary file that contains byte-code. Byte-code

More information

Repetition CSC 121 Fall 2014 Howard Rosenthal

Repetition CSC 121 Fall 2014 Howard Rosenthal Repetition CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Chem 3BA3 Quantum Mechanics and Spectroscopy I Course Content: Textbook: Dykstra Recommended Additional Reading: Garland Nibler Shoemaker Levine

Chem 3BA3 Quantum Mechanics and Spectroscopy I Course Content: Textbook: Dykstra Recommended Additional Reading: Garland Nibler Shoemaker Levine Chem 3BA3 Course Outline - Fall 2005 Quantum Mechanics and Spectroscopy I Prof. P. Kruse, ABB-263, x23480, pkruse@mcmaster.ca http://www.chemistry.mcmaster.ca/kruse/ version 09 Sept 2005 Welcome to Introductory

More information

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 5. Repetition in Programs. Notes. Notes. Notes. Lecture 05 - Loops

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 5. Repetition in Programs. Notes. Notes. Notes. Lecture 05 - Loops Computer Science & Engineering 150A Problem Solving Using Computers Lecture 05 - Loops Stephen Scott (Adapted from Christopher M. Bourke) 1 / 1 Fall 2009 cbourke@cse.unl.edu Chapter 5 5.1 Repetition in

More information

CSC 121 Spring 2017 Howard Rosenthal

CSC 121 Spring 2017 Howard Rosenthal CSC 121 Spring 2017 Howard Rosenthal Agenda To be able to define computer program, algorithm, and highlevel programming language. To be able to list the basic stages involved in writing a computer program.

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30 CS31 Discussion 1E Jie(Jay) Wang Week1 Sept. 30 About me Jie Wang E-mail: holawj@gmail.com Office hour: Wednesday 3:30 5:30 BH2432 Thursday 12:30 1:30 BH2432 Slides of discussion will be uploaded to the

More information

AP Computer Science Principles Programming Question Tips. 1: Which algorithm/code segment achieves some result?

AP Computer Science Principles Programming Question Tips. 1: Which algorithm/code segment achieves some result? AP Computer Science Principles Programming Question Tips Name: Recall that roughly 40 percent of the questions on the AP exam will be programming or algorithm questions. These will often fall into one

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa Course Basics A new 7 credit unit course Replaces OHJ-2156 Analysis of Algorithms We take things a bit further than OHJ-2156 We will assume familiarity

More information

Chapter Goals. Contents LOOPS

Chapter Goals. Contents LOOPS CHAPTER 4 LOOPS Slides by Donald W. Smith TechNeTrain.com Final Draft Oct 30, 2011 Chapter Goals To implement while, for, and do loops To hand-trace the execution of a program To become familiar with common

More information

COMP-202 Unit 4: Programming with Iterations

COMP-202 Unit 4: Programming with Iterations COMP-202 Unit 4: Programming with Iterations Doing the same thing again and again and again and again and again and again and again and again and again... CONTENTS: While loops Class (static) variables

More information

QUIZ. Name all the 4 parts of the fetch-execute cycle.

QUIZ. Name all the 4 parts of the fetch-execute cycle. QUIZ Name all the 4 parts of the fetch-execute cycle. 1 Solution Name all the 4 parts of the fetch-execute cycle. 2 QUIZ Name two fundamental differences between magnetic drives and optical drives: 3 QUIZ

More information

CS 101 Fall 2006 Midterm 1 Name: ID:

CS 101 Fall 2006 Midterm 1 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

CS157a Fall 2018 Sec3 Home Page/Syllabus

CS157a Fall 2018 Sec3 Home Page/Syllabus CS157a Fall 2018 Sec3 Home Page/Syllabus Introduction to Database Management Systems Instructor: Chris Pollett Office: MH 214 Phone Number: (408) 924 5145 Email: chris@pollett.org Office Hours: MW 4:30-5:45pm

More information

CS 323 Lecture 1. Design and Analysis of Algorithms. Hoeteck Wee

CS 323 Lecture 1. Design and Analysis of Algorithms. Hoeteck Wee { CS 323 Lecture 1 } Design and Analysis of Algorithms Hoeteck Wee hoeteck@cs.qc.cuny.edu http://cs323.qwriting.org/ Algorithmic ideas are pervasive APPLICATIONS. Economics, auctions and game theory Biology,

More information

The Specification Phase

The Specification Phase The Specification Phase CS427: Elements of Software Engineering Lecture 4.1 10am, 30 Jan 2012 CS427 The Specification Phase 1/16 Outline 1 Recall... The Requirements Phase 2 Phase 2: Specifications 3 Requirements

More information

Searching Algorithms/Time Analysis

Searching Algorithms/Time Analysis Searching Algorithms/Time Analysis CSE21 Fall 2017, Day 8 Oct 16, 2017 https://sites.google.com/a/eng.ucsd.edu/cse21-fall-2017-miles-jones/ (MinSort) loop invariant induction Loop invariant: After the

More information

CS 200, Section 1, Programming I, Fall 2017 College of Arts & Sciences Syllabus

CS 200, Section 1, Programming I, Fall 2017 College of Arts & Sciences Syllabus Northeastern Illinois University CS 200, Section 1, Programming I, Fall 2017 Syllabus, Page 1 of 7 CS 200, Section 1, Programming I, Fall 2017 College of Arts & Sciences Syllabus COURSE INFORMATION: Credit

More information

CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion

CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion CS61A Notes Week 1A: Basics, order of evaluation, special forms, recursion Assorted Scheme Basics 1. The ( is the most important character in Scheme. If you have coded in other languages such as C or Java,

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be

More information