MSIS 655 Advanced Business Applications Programming

Slides:



Advertisements
Similar presentations
4 Control Statements: Part 1.
Advertisements

Control Structures Selections Repetitions/iterations
More on Algorithms and Problem Solving
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
 Control structures  Algorithm & flowchart  If statements  While statements.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter4: Control Statements Part I.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
 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
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Introduction to Computers and Programming More Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Control Structure.
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.
 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.
Structured Program Development in C
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
 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.
Chapter 4 Control Statements: Part I
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.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
© 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.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 3.
Programming in Java Unit 4. Learning outcome:  LO2: Be able to design Java solutions  LO3: Be able to implement Java solutions Assessment criteria:
Dale Roberts Program Control using Java - Selection Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
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.
1 C++ How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved. 4.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Program Control using Java - Repetition Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
 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.
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.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
1 Lecture 2 Control Structures: Part 1 Selection: else / if and switch.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Chapter 3 Structured Program Development in C C How to Program, 8/e, GE © 2016 Pearson Education, Ltd. All rights reserved.1.
Chapter 7 JavaScript: Control Statements, Part 1
Chapter 4 – C Program Control
Algorithm: procedure in terms of
Control Statements: Part 1
Control Statements: Part 1
JavaScript: Control Statements I
Chapter 8 - JavaScript: Control Statements I
CSC113: Computer Programming (Theory = 03, Lab = 01)
Ch 7: JavaScript Control Statements I.
Chapter 4 – Control Structures Part 1
JavaScript: Control Statements.
JavaScript: Control Statements I
Chapter 4- part 2 Control Statements: Loops 1
Program Control using Java - Theory
Chapter 4 Control Statements: Loops 1
Structured Program
Chapter 3 - Structured Program Development
3 Control Statements:.
Chapter 3 – Control Structures
Chapter 3 - Structured Program Development
Chapter 4 - Control Structures: Part 1
EPSII 59:006 Spring 2004.
Structural Program Development: If, If-Else
Presentation transcript:

MSIS 655 Advanced Business Applications Programming Week 3 Control Structure, Part 1 In this chapter you will learn: To use basic problem-solving techniques. To develop algorithms through the process of top-down, stepwise refinement. To use the if and if else selection statements to choose among alternative actions. To use the while repetition statement to execute statements in a program repeatedly. To use counter-controlled repetition and sentinel-controlled repetition. 12/1/2018 3.1

Control Structure Algorithms are series of actions in certain order in which actions execute. Program control is to specify the order in which those actions are executed. Control Structures (transfer of control) Sequence Selection (Decision) Repetition Java has a built-in sequence structure – program statements execute one after the other from the beginning to the end unless otherwise (other structures were) specified. Java provides three selection structures if if / else switch Java provides three repetition (loop) structures while do / while do These words are Java keywords. Keywords: Appendix C on page 1401. 12/1/2018

Algorithm and Problem Solving Experience has shown that the most difficult part of solving a problem on a computer is developing the algorithm for the solution. Once a correct algorithm has been specified, the process of producing a working Java program from the algorithm is normally straightforward. 12/1/2018

Flowcharting add grade to total add 1 to counter Flowlines Action Symbols add grade to total total = total + grade; add 1 to counter counter = counter +1; Other Methodologies of Software Design Pseudocode An informal language similar to English Helps programmers develop algorithms Does no run on computers Should contain input, output and calculation actions Should not contain variable declarations UML activity diagram (www.uml.org) – Learn in MSIS 670 Models the workflow (or activity) of a part of a software system Action-state symbols (rectangles with their sides replaced with outward-curving arcs) represent action expressions specifying actions to perform Diamonds Decision symbols (explained in section 4.5) Merge symbols (explained in section 4.7) Connector Symbols 12/1/2018

Flowchart Symbols Experience has shown that the most difficult part of solving a problem on a computer is developing the algorithm for the solution. Once a correct algorithm has been specified, the process of producing a working Java program from the algorithm is normally straightforward. 12/1/2018

The if selection structure grade >=60 true print “Passed” Selection Statements if statement Single-selection statement if…else statement Double-selection statement switch statement – Chapter 5 Multiple-selection statement if statements Execute an action if the specified condition is true Can be represented by a decision symbol (diamond) in a UML activity diagram Transition arrows out of a decision symbol have guard conditions Workflow follows the transition arrow whose guard condition is true false 12/1/2018

The if / else selection structure grade >=60 true false print “Passed” print “Failed” if…else statement Executes one action if the specified condition is true or a different action if the specified condition is false Conditional Operator ( ? : ) Java’s only ternary operator (takes three operands) ? : and its three operands form a conditional expression Entire conditional expression evaluates to the second operand if the first operand is true Entire conditional expression evaluates to the third operand if the first operand is false Note: Conditional expressions are more difficult to read than if else statements and should be used to replace only simple if else statements that choose between two values. 12/1/2018

The while repetition structure product <=1000 true product = 2* product Repetition statements Also known as looping statements Repeatedly performs an action while its loop-continuation condition remains true while statement Performs the actions in its body zero or more times do…while statement (Ch. 5) Performs the actions in its body one or more times for statement (Ch. 5) Repeats an action while its loop-continuation condition remains true Uses a merge symbol in its UML activity diagram Merges two or more workflows Represented by a diamond (like decision symbols) but has: Multiple incoming transition arrows, Only one outgoing transition arrow and No guard conditions on any transition arrows false 12/1/2018

Formulating Algorithms: Repetition Counter-controlled repetition Use a counter variable to count the number of times a loop is iterated Sentinel-controlled repetition Also known as indefinite repetition Use a sentinel value (also known as a signal, dummy or flag value) A sentinel value cannot also be a valid input value Initialize each counter and total, either in its declaration or in an assignment statement. Totals are normally initialized to 0. Counters are normally initialized to 0 or 1, depending on how they are used (we will show examples of when to use 0 and when to use 1). 12/1/2018

while loop iterates as long as gradeCounter <= 10 12/1/2018

while loop iterates as long as grade != the sentinel value, -1 12/1/2018

Lab activities (Week 6) Exercises (p. 177) 4.30, 4.31, 4.32, 4.35, 4.36 This problem should be similar to the example just we reviewed. Maybe different GUIs are necessary. Check the examples in the book, you will be able to find necessary stuff. 12/1/2018