Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Control Structure.

Slides:



Advertisements
Similar presentations
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Advertisements

Chapter 04 (Part III) Control Statements: Part I.
 Control structures  Algorithm & flowchart  If statements  While statements.
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Chapter 3 - Structured Program Development
 2001 Deitel & Associates, Inc. All rights reserved. 1 Outline 14.1Introduction 14.2Algorithms 14.3Pseudocode 14.4Control Structures 14.5The if Selection.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
Fall 2008Yanjun Li CSRU JavaScript: Control Statements I Internet & World Wide Web:
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Structured Program Development in C
Lecture 3 Structured Program Development in C
 2002 Prentice Hall. All rights reserved. 1 Chapter 3 – Control Structures Outline 3.1 Introduction 3.2 Algorithms 3.3 Pseudocode 3.4Control Structures.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
The University of Texas – Pan American
 2003 Prentice Hall, Inc. All rights reserved.  2004 Prentice Hall, Inc. All rights reserved. Chapter 8 - JavaScript: Control Statements I Outline 8.1.
Spring 2005, Gülcihan Özdemir Dağ Lecture 3, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 3 Outline 3.1 Introduction.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
C Lecture Notes 1 Structured Program Development.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
 2007 Pearson Education, Inc. All rights reserved Structured Program Development in C.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Control Structures: Part 1.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
C Programming 2002 Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 8 - JavaScript: Control Statements I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
1 Lecture 3 Control Structures else/if and while.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
Chapter 3 Structured Program Development Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Lecture 5: Layers of Control. Nested while Loops Problem Multiplying two numbers and outputting the result only if they are both less than 5. (i.e. Start.
CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad.
1 JavaScript/Jscript 2 Control Structures I. 2 Introduction Before programming a script have a –Thorough understanding of problem –Carefully planned approach.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (while) Outline 3.7The While Repetition.
JavaScript: Control Structures I Outline 1 Introduction 2 Algorithms 3 Pseudocode 4 Control Structures 5 if Selection Structure 6 if/else Selection Structure.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
 2007 Pearson Education, Inc. All rights reserved Structured Program Development in C.
1 Chapter 4 - Control Statements: Part 1 Outline 4.1 Introduction 4.4 Control Structures 4.5 if Selection Structure 4.6 if/else Selection Structure 4.7.
Chapter 14 - JavaScript/JScript: Control Structures I
Chapter 7 JavaScript: Control Statements, Part 1
Algorithm: procedure in terms of
JavaScript: Control Statements I
Chapter 8 - JavaScript: Control Statements I
Ch 7: JavaScript Control Statements I.
JavaScript: Control Statements I
Chapter 8 - JavaScript: Control Structures I
MSIS 655 Advanced Business Applications Programming
Structured Program
Chapter 3 - Structured Program Development
3 Control Statements:.
Chapter 3 - Structured Program Development
EPSII 59:006 Spring 2004.
Chapter 8 - JavaScript: Control Structures I
Structural Program Development: If, If-Else
Presentation transcript:

Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Control Structure

Algorithms Actions to be executed Order in which the actions are to be executed Pseudocode: informal representation of an algorithm – If prepared carefully, pseudocode statements can be converted in to actual programming code in a fairly straightforward fashion

Control Structures Elements of code that define an individual action Like most programming languages, JavaScript has three control structures: – Sequence structure Any individual non-selection and non-repetition statement falls into this category: individual calculation, input or output statement, type conversion, etc. – Selection structure: three in JavaScript if if … else switch – Repetition structure: four in JavaScript while do … while for for … in

if Selection Statement Single-entry/single-exit structure Indicate action only when the condition evaluates to true. No action for false grade >= 60 true false print “Passed”

if…else Selection Statement Indicate different actions to be perform when condition is true or false grade >= 60 true print “Failed” false print “Passed” Conditional operator ( ?: ) (see page 217), closely related to if…else – JavaScript’s only so called “ternary” operator Three operands Forms a conditional expression

Nested if…else Selection Statement When we have one decision criterion but with multiple and mutually exclusive range of values If student = “Senior” … Else if student = “Junior” … Else if student = “Sophomore” … Else … – Switch clause can be used instead When we have more than one decision criterion – for example when making decisions based on combined values of variable “age” and “income”: – Logic errors vs. syntax errors – Can be simplified by using logical AND (&&), OR (||) operators In class example

while Repetition Statement Repetition structure (loop) – Repeat action while some condition remains true product <= 1000 product = 2 * product true false

Formulating Algorithms: Example 1 (Counter-Controlled Repetition) Counter-controlled repetition – Counter Control the number of times a set of statements executes – Definite repetition

Outline average.html (1 of 3)

Outline average.html (2 of 3)

Outline average.html (3 of 3)

Example 2 (Sentinel-Controlled Repetition) Indefinite repetition – Sentinel value indicates the end of data entry: should be out of range of acceptable values

Outline average2.html (1 of 3)

Outline average2.html (2 of 3)

Outline average2.html (3 of 3)

Example 3 (Nested Control Structures) Consider problem Make observations Top-down, stepwise refinement

Outline analysis.html (1 of 2)

Outline analysis.html (2 of 2)

Assignment Operators Compound assignment operators – Abbreviate assignment expressions

8.13 Note on Data Types Loosely typed – Automatically converts between values of different types