15 Pages

Lect7JSLoops

Course: WEEK 122, Spring 2009
School: Maryland
Rating:
 
 
 
 
 

Word Count: 759

Document Preview

Instructor: Announcements Nelson Padua-Perez (nelson@cs.umd.edu) No posting of code in the forum Check class announcements daily You must implement programming projects by yourself 1 JavaScript Reference https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference 2 JavaScript (If Statement) What is the difference between === and == ? Let's compare 20 === "20" vs. 20 ==...

Register Now

Unformatted Document Excerpt

Coursehero >> Maryland >> Maryland >> WEEK 122

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Instructor: Announcements Nelson Padua-Perez (nelson@cs.umd.edu) No posting of code in the forum Check class announcements daily You must implement programming projects by yourself 1 JavaScript Reference https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference 2 JavaScript (If Statement) What is the difference between === and == ? Let's compare 20 === "20" vs. 20 == "20" 3 JavaScript (Logical Operators) Used with comparison operators to create more complex expressions Operators Logical and (&&) expr1 && expr2 Expression is true if and only if both expressions are true otherwise is false You can have more than two expressions Example: LogicalOp1.html Logical or (||) expr1 || expr2 Expression is false if and only if both expressions are false otherwise is true You can have more than two expressions Example: LogicalOp2.html Logical Not (!) !expr Inverts the boolean value of the expression 4 Precedence/Associativity Remember you can use parenthesis to impose a particular order for the evaluation of an expression 5 Cascaded If Statement Idiom You can combine if statements to handle different cases This approach to organize if statements to handle different cases is called the Cascaded If Statement Cascaded If statement general form: If (expr1) { // Statements executed if expr1 is true } else if (expr2) { // Statements executed if expr2 is true } else if (expr3) { // Statements executed if expr3 is true } else { // If none of the above expressions is true } Notice it is not a JavaScript statement Once one of the cases is executed no other case will be executed You don't need to use { } if you only have one statement More efficient than having multiple if statements Example: See CascadedIf.html 6 while Statement while statement Control statement which allows JavaScript to repeat a set of statements Basic Form while (expression) { statement(s) // executed as long as expression is true } { } not needed if you only have one statement You can have other types of statements (including whiles) in a while Common mistake: to add a semicolon after closing parenthesis Example: Numbers.html Example: EvenNumbers.html Example: NumbersTable.html Example: SqrtTable.html 7 Trace Tables Mechanism to keep track of values in a program Allows you to understand the program behavior We could create a trace table for EvenNumbers.html 8 Combination of Statements Keep in mind that you can have any combination of conditionals, and iteration (while) statements For example: Conditionals insides loops of Conditionals inside conditionals Loops inside conditionals Loops inside of loops 9 Infinite Loops An infinite loop occurs when the expression controlling the loop never becomes false Example1 int x = 30; while(x > 0) { document.writeln("<li>Element</li>"); } Example2 int x = 7; // how about x = 8 while (x != 0) { document.writeln("<li>Element</li>"); x=x 2; } How can we detect infinite loops? 10 Programming Errors Syntax Error: (Compile-time error) The program violates the language's grammar Semantic Error: The program fails to accomplish what we want Debugging: The process of finding and fixing errors. Extremely hard for large software systems. Tools for debugging: Trace tables Output statements Debuggers Analogy: Taco tom ate. Syntactically therefore semantically incorrect. A taco ate tom. Syntactically correct however semantically incorrect. Tom ate a taco Syntactically and semantically correct (what we want!) 11 How to find problems in your code Computer programming is not about writing code and letting someone else find the problems (bugs) it may have You have to learn how to find problems in your code Approach Use Error Console to see possible error Use JavaScript Lint http://www.javascriptlint.com/online_lint.php How about logical errors? 12 Introduction to Debugging How to debug your code? Introducing the alert() function 13 Suggestions for Solving Problems Using a Programming Language Design Make sure you first come up ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Maryland - WEEK - 122
Announcements Check class announcements daily You must implement programming projects by yourself1Miscellaneous Propertiestext-indent specifies the indentation to use for the first line of a block line-height height of a line of text lett
Maryland - WEEK - 122
Announcements Check class announcements daily You must implement programming projects by yourself1Designing Using Pseudocode So far we have focused on the syntax and semantics of JavaScript As the complexity of problems increase you need
American - SL - 2086
Sarah Langford Dr. Assenov SIS 600 9 December 2008Do Educated and Employed Women Have Fewer Children? Research Questions:The research area in which I am interested is the relationship between the amount of education and employment in which women a
Columbia - V - 1001
&lt;html&gt;&lt;head&gt;&lt;title&gt;Earth's Cycles&lt;/title&gt;&lt;/head&gt;&lt;BODY BGCOLOR=&quot;#FFFFFF&quot;&gt;&lt;A HREF=&quot;http:/rainbow.ldeo.columbia.edu/courses/s4021/coursenotes.html&quot;&gt;BACK TO COURSE NOTES&lt;/A&gt;&lt;P&gt;&lt;H2&gt;&lt;center&gt;Earth's Cycles&lt;/center&gt;&lt;/H2&gt;&lt;B&gt;&lt;/B&gt;&lt;P&gt;I. We have seen how
Maryland - CMSC - 122
CMSC122 Quiz 1 WorksheetThe first quiz for the course will be on Friday, Jun 12 at the beginning of the class (11:00 am). The following list provides more information about the quiz: The quiz will be a written quiz (no computer). Closed book, clo
Maryland - CMSC - 122
CMSC 122 Quiz 2 WorksheetThe third quiz for the course will be on Friday, June 19 at the beginning of the class (11:00 am). The following list provides more information about the quiz: The quiz will be a written quiz (no computer). Closed book, c
Maryland - CMSC - 132
Abstract/Inner Class Exercise Exercises1. Define a class named Factorial that has the following methods: a. Constructor - Factorial(lowerLimit, upperLimit) b. Implement an iterator which will return the factorials of numbers starting at lowerLimit a
Maryland - CMSC - 132
Initialization Block/GUI Exercise Exercises1. Rewrite the Athlete.java class so it now uses a non-static initialization block in order to implement the initialization performed by the private method init.2. The following exercises rely on the code
Maryland - CMSC - 132
CMSC 132 BIG-O Exercise1. List the following big-O expressions in order of asymptotic complexity (with the lowest complexity first).O(nlog(n) O(n!) O(log(n) O(2n) O(n2)2. For each of the following code snippets, identify the critical section(s),
Maryland - CMSC - 132
CMSC 132 Quiz 1 WorksheetThe first quiz for the course will be on Friday, June 12. The following list provides more information about the quiz: The quiz will be a written quiz (no computer). The quiz will be in your lab (discussion) session. Clo
Rose-Hulman - MA - 111
MA 111Integration and Summation Review Quiz Fall 2003-2004Instructions: Do all problems, without the aid of any books, notes, calculators, or computers.ni=i=1n(n + 1) , 2ni2 =i=1n(n + 1)(2n + 1 ,. 6ni3 =i=1n2 (n + 1)2 41.x
Wisc Parkside - ACCT - 201
Wisc Parkside - ACCT - 201
Financial AccountingACCT 201 1. DefinitionAccounting is the process of identifying, measuring, recording and communicating information about a company to users for making economic decisions 2. Role of Accounting in SocietyCorpor
Wisc Parkside - ACCT - 201
Ch.2 Financial Statements and the Annual ReportProf. Jamie WangWhat Financial Statements Tell about a Business B/S: How much of the assets was borrowed, and how much provided by its shareholders What obligations will be due in the near future
Wisc Parkside - ACCT - 201
Ch.3 The Accounting Process Step #1: Analyzing transactions Step #2: Recording transactions Step #3: Posting transactions Step #4: Prepare a trial balance (T.B.) Step #5: Make adjusting entries Step #6: Prepare an adjusted T.B. Step #7: Prepare finan
Wisc Parkside - ACCT - 201
Ch.4 Income Measurement &amp; Accrual AccountingChapter 4, Slide #1Recognition and Measurement Recognition: formallyrecording an item in the financial statements of an entityI know I need to record this..but at current value or historical cos
Wisc Parkside - ACCT - 201
Ch.5 Accounting for Inventories and Cost of Goods Sold Prof. J. WangChapter 5, Slide #1Part I IntroductionChapter 5, Slide #2 1. merchandise inventory 2. I/S of a merchandise company 3. how companies keep track of their inventory: perpetual
Wisc Parkside - ACCT - 201
Ch.6 Cash and Internal ControlProf. J. Wang Part I Internal Control Internal Control SystemConsists of the policies and procedures necessary to ensure: The safeguarding of an entity's assets The reliability of its accounting r
Wisc Parkside - ACCT - 201
Ch.7 Investments &amp; ReceivablesChapter 7, Slide #1Part I Investments (FYI only)Chapter 7, Slide #2Types of Investments Investment in treasury bills Investment in a CD Investment in other companies' bonds Investment in other companies' stoc
Wisc Parkside - ACCT - 201
Ch.9 Current Liabilities and Time Value of Money Part I: Current Liabilities Current liabilities: Require payment within one year (or one operating cycle whichever is longer) Jacuzzi Brands Partial Balance Sheet 2004Liabilities and
Wisc Parkside - ACCT - 201
Ch.12 Statement of Cash FlowsProf. J. WangChapter 12, Slide #1 How to read statement of cash flows How to prepare statement of cash flowsChapter 12, Slide #2Part I How to read statement of cash flows?Chapter 12, Slide #3 How much cash
Wisc Parkside - ACCT - 201
Ch.13 Financial Statement AnalysisFinancial Statement AnalysisWill I be paid?How good is our investment?CreditorsStockholdersF/S Analysis Requires Proper ComparisonsOver time for the same companyTrend/horizontal analysis Ratio analysi
Wisc Parkside - ACCT - 201
Ch.3 The Accounting Process Step #1: Analyzing transactions Step #2: Recording transactions Step #3: Posting transactions Step #4: Prepare a trial balance (T.B.) Step #5: Make adjusting entries Step #6: Prepare an adjusted T.B. Step #7: Prepare finan
Wisc Parkside - ACCT - 201
Ch.9 Current Liabilities and Time Value of Money Part I: Current Liabilities Current liabilities: Require payment within one year (or one operating cycle whichever is longer) Jacuzzi Brands P
Maryland - CMSC - 330
A-PDF PPT TO PDF DEMO: Purchase from www.A-PDF.com to remove the watermark! &quot;&amp;! &quot; ! &quot;#$'( ) &amp;* ,%&amp;* , +&amp;! ! &quot; ! .+'$ $ , $ *&amp;/'+
Maryland - CMSC - 330
Last lecture LanguagesCMSC330Finite Automata Sets of strings Operations on languages Regular expressions Constants Operators Precedence12This lecture Finite automata States Transitions ExamplesImplementing Regular Expressions
Maryland - CMSC - 330
Last Lecture Finite automataCMSC330Finite Automata 2 Alphabet, states. ( , Q, q0, F, ) Reducing RE to NFA Concatenationa b a b Types Deterministic (DFA)a b Union Non-deterministic (NFA) aa ClosureaThis Lecture Reducing NFA
Maryland - CMSC - 330
Last time CMSC330Ocaml NFA -&gt; DFA DFA minimization DFA complement12This time OcamlFeatures of ML &quot;Mostly functional&quot; Some assignments Higher-order functions Functions can be parameters and return values Type inference No need to
Washington - CHEM - 237
Chemistry 237, Winter 2009 MWF 3:30-4:20 pm, Bagley 131Instructor: Professor Andrei Straumanis e-mail: Andrei2@u.washington.edu Mailbox: Bagley Office Location: CHB 404J Office Hours: M 2:15-3:15; W 4:20-5:20 (in our classroom, Bagley 131) or by app
Georgia Tech - ECE - 2025
ECE-2025Fall-01INFORMATION LABS Room 252 in VanLeer Building MATLAB based computer projects MATLAB Help: next week in the eveningsLECTURE #1 Sinusoids 20-Aug-01 RECITATIONS Room 361 in VanLeer Building EMPHASIS on Problem Solving GRAD
Georgia Tech - ECE - 2025
GEORGIA INSTITUTE OF TECHNOLOGYSCHOOL of ELECTRICAL and COMPUTER ENGINEERINGEE 2200 Winter 1999 Problem Set #3Assigned: 22 Jan 1998 Due Date: 29 Jan 1998 (F RIDAY ) Quiz #1 will be held in lecture on Monday 1-Feb-99. It will cover material from C
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IICourse IntroductionDepartment of Computer Science University of Maryland, College ParkCourse Catalog DescriptionIntroduction to use of computers to solve problems using software engineering principles Des
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIObject-Oriented Programming IntroDepartment of Computer Science University of Maryland, College Park1Object-Oriented Programming (OOP)Approach to improving softwareView software as a collection of objec
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIJava Language ConstructsDepartment of Computer Science University of Maryland, College Park1Review of Java Language ConstructsBasic elementsPrimitive types, variables, constants, operators If-else, swi
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIAbstract ClassesDepartment of Computer Science University of Maryland, College ParkModifier AbstractDescriptionRepresents generic concept Just a placeholder Leave lower-level details to subclassApplie
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIJava Support for OOPDepartment of Computer Science University of Maryland, College ParkObject Oriented Programming (OOP)OO PrinciplesAbstraction EncapsulationAbstract Data Type (ADT)Implementation ind
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIProgram Correctness, ExceptionsDepartment of Computer Science University of Maryland, College ParkOverviewProgram correctness is determined by the presence / absence of program defects (errors) IssuesTyp
Oregon - MATH - 241
Practice.Lecture 14.We are going to devote today to practice with computing derivatives. On the last page we have a summary of the differentiation rules that we shall focus on. 1. For f (x) = x2ex, find f (x) =t2 , find 2. For g(t) = ln(2t) g (
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIJava Inner ClassesDepartment of Computer Science University of Maryland, College Park1OverviewClassesTop-level vs. inner &amp; nestedInner classesIterator example Used inside outer classAnonymous inne
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIGraphical User Interface (GUI)Department of Computer Science University of Maryland, College Park1Graphical User Interface (GUI)User interfaceInterface between user and computer Both input and output A
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIAlgorithmic Complexity IDepartment of Computer Science University of Maryland, College Park1Algorithm EfficiencyEfficiencyAmount of resources used by algorithm Time, spaceMeasuring efficiencyBenchma
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIAlgorithmic Complexity IIDepartment of Computer Science University of Maryland, College Park1OverviewCritical sections Comparing complexityTypes of complexity analysis2Analyzing AlgorithmsGoalFi
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IICollection Abstractions &amp; Java CollectionsDepartment of Computer Science University of Maryland, College ParkCollectionPrograms represent and manipulate abstractions (chunks of information)Examples: rost
Maryland - WEEK - 132
CMSC 132: Object-Oriented Programming IIGeneric ProgrammingDepartment of Computer Science University of Maryland, College ParkGeneric ProgrammingGeneric programmingDefining constructs that can be used with different data types I.e., using same
Minnesota - STRE - 0252
Georgia Tech - CS - 1321
CS 1321CS1321: Introduction to ProgrammingGeorgia Institute of Technology College of Computing Lecture 27 November 29, 2001 Fall SemesterToday's Menu1. InheritanceIn Our Last Episode.In our last lecture, we began our exploration of the Objec
Washington - PH - 122
Density = Mass/Volume P = g h in a fluidPressure P = Force/AreaAtmospheric pressure is approximately 105 N/m2 1000 liters = 1m3 Density of water = 1 gm/cm3 = 1000 kg/m3 Density of air = 1.29 kg/m3 0o C = 273.15 K Heat Capacity: C = Q/T 1 cal =
Ball State - MUMET - 427
MAXGetting StartedTable of ContentsIntroduction: What is Max? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 How To Use The Manuals ; Manual Conventions; ;Other Resources f
Ball State - MUMET - 427
MAXTutorials and TopicsTable of ContentsIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Tutorial 1: Saying &quot;Hello!&quot; . . . . . . . .
Ball State - MUMET - 427
MAXReferenceCopyright and Trademark NoticesThis manual is copyright 2000-2003 Cycling '74. Max is copyright 1990-2003 Cycling '74/IRCAM, l'Institut de Recherche et Cordination Acoustique/Musique.CreditsOriginal Max Documentation: Chris Dobr
Ball State - MUMET - 427
MSPGetting Started Tutorials and Topics ReferenceTable of ContentsIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Digital Audio: How
Kennesaw - MATH - 1190
22.12.1.1Differentiation rules (Ch. 3)Polynomial and exponential functions (3.1, 3.2)Constant RuleLet C denote any constant. Then we have (C) = 0 or using Leibniz notation dC =0 dx It is easy to see why this rule holds. A constant function do
Kennesaw - MATH - 1190
128CHAPTER 3. APPLICATIONS OF THE DERIVATIVE3.53.5.1Using the Second Derivative to test Critical Numbers (4.3)Theory:The sign of the .rst derivative tells us whether a function is increasing or decreasing. However, this notion is not precis
Kennesaw - MATH - 1190
4SolutionsExercise 16 When an object is thrown upward, its altitude h is given as a function of time by the following relation: h (t) = -16t2 + 64t + 6. In this relation, t is expressed in seconds, h in feet. 1. Find the average velocity of the o
Kennesaw - MATH - 1190
Chapter 2Rules of Dierentiation2.1 Preliminary: Pattern MatchingBeing able to apply the rules of dierentiation successfully is an exercise in pattern matching. You are given a function, you will have to recognize which pattern it follows. The pa
Kennesaw - MATH - 1190
Differentiation RulesPhilippe B. Laval Kennesaw State UniversityAbstract This handout is a summary of the most commonly used differentiation rules students should know for Calculus I and beyond. It also contains practice problems.11.1Differen
Kennesaw - MATH - 1190
16CHAPTER 1. LIMITS AND CONTINUITY1.21.2.1LimitsIntroductionx!aWe are trying to study the behavior of a given function f (x) near a given value x = a. This is denoted by the symbol lim f (x). It is read &quot;limit of f (x) as x approaches a&quot;.
Kennesaw - MATH - 1190
Practice Problems for Maple and/or the java appletsPhilippe B. Laval Kennesaw State University January 12, 2009Abstract This handout is a list of practice problems for Maple and/or the java applets available on my site.11.1Practice problemsPr
Kennesaw - MATH - 1190
82CHAPTER 2. VECTOR FUNCTIONS2.5Velocity and AccelerationIn this section, we study the motion of an object along a space curve. In other words, as the object moves with time, its trajectory follows a space curve. We will see how the notions o
Kennesaw - MATH - 1190
2.3. PRODUCT AND QUOTIENT RULES632.32.3.1Product and Quotient RulesProduct rule(f (x) g (x) = f (x) g (x) + f (x) g (x)Suppose that f and g are two differentiable functions. ThenSee 2.3.5 on page 65 for a proof. Example 111 Find x2 ex x2
Kennesaw - MATH - 1190
Mathematics 1190, ProjectApril 7, 2004Philippe B. LavalNameDo not forget to put your name. This project is to be done in groups of 2 or 3 (no more than 3) students. One project per group will be turned in no later than Wednesday April 21, 2004