Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Advertisements

Program Flowchart, Pseudocode & Algorithm development
Flow Charts, Loop Structures
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Subject: Information Technology Grade: 10
Fundamentals of Algorithms MCS - 2 Lecture # 4
CS 1400 Course Reader Introduction. What is Programming? Designing an appropriate algorithm Coding that algorithm in a computer language.
Chapter 2: Input, Processing, and Output
An Overview of Computers and Logic
An Overview of Programming Logic and Design
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 3 Planning Your Solution
Pseudocode.
Chapter 3 Planning Your Solution
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
Problem Solving with the Sequential Logic Structure Lesson 5 McManusCOP10061.
Problem Solving with Decisions
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 1 Introduction to Structured Design. Introduction  System  A combination of people, equipment, and procedures that work together to perform.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Programming and Languages
Chapter 14 Programming and Languages McGraw-Hill/Irwin Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Flowcharts C++ Lab. Algorithm An informal definition of an algorithm is: a step-by-step method for solving a problem or doing a task. Input data A step-by-step.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Introduction to Flowcharts
Chapter 11 Inheritance © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured and Object-Oriented.
Chapter 7 CASE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
An Introduction to Programming with C++1 More on the Selection Structure Tutorial 7.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
ALGORITHMS AND FLOWCHARTS
Chapter 8: More on the Repetition Structure
Chapter 6 JavaScript: Introduction to Scripting
Input and Output Upsorn Praphamontripong CS 1110
1-1 Logic and Syntax A computer program is a solution to a problem.
Exam 1 Review.
Chapter 2: Input, Processing, and Output
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
The Selection Structure
Chapter 4: The Selection Structure
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Numbering System TODAY AND TOMORROW 11th Edition
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Introduction to pseudocode
Programming Right from the Start with Visual Basic .NET 1/e
Chapter 3: Introduction to Problem Solving and Control Statements
1) C program development 2) Selection structure
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
ME 142 Engineering Computation I
Problem Solving.
Microsoft Visual Basic 2005: Reloaded Second Edition
Boolean Expressions to Make Comparisons
Flowcharts and Pseudo Code
Chapter 2: Input, Processing, and Output
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured and Object-Oriented Design, 7e

Introduction In a SIMPLE SEQUENCE the steps are carried out in a sequential manner.  It may be desirable to vary the sequence of processing steps carried out within a solution algorithm.

Billing Problem (Flowchart)‏

Billing Example Decision symbol  The diamond-shaped symbol.  A choice between two alternative paths, or sequences of instructions, is made.

Pseudocode  Similar to some high-level programming languages, but it does not require that we follow strict rules as we would if actually writing a program.

Pseudocode—Introduction

IFTHENELSE Control Structure IFTHENELSE control structure  A small, circular symbol, called a connector symbol, is used to represent the decision-making logic within the IFTHENELSE pattern

IFTHENELSE--Generic

Time Card Problem

Time Card Example No-function condition—null ELSE  The no-function condition is represented by enclosing the key-word ELSE in parentheses.

Sample Problem 3.1 Payroll Problem  Compute the pay for an employee.  Regular pay will be computed as hours (through 40) times rate.  Overtime pay (1.5 times hours times rate) for all hours worked over 40.

Payroll Problem (Flowchart)‏

Payroll Problem (Flowchart) cont.

Payroll Problem (Pseudocode)‏

Finding the Smallest Number (Flowchart)‏

Finding the Smallest Number (Pseudocode)‏

Sample Problem 3.3 Bank Problem  Compute the new balance in a customer's bank account. A deposit (code of 1) or withdrawal (code of 2)‏

Bank Problem (Flowchart)‏

Bank Problem (Flowchart) cont.

Bank Problem (Pseudocode)‏

Character-String Constant The following information would be output as a result of 3 being input and the WRITE statement:  Designate character-string by enclosing it in single or double quotation marks, distinguishing it from a variable name.  If we included the variable name CODE within the quotation marks:

Character-String Constant  Assign the value of a character-string constant to a variable by means of a statement.  Use a character-string constant in a decision statement.  Compared to the letter D.  Compared to the value of the variable D.

Sample Problem 3.4 Sales Problem  The commission rate is based on two factors, the amount of sales and the class to which the sales person belongs.

Sample Problem 3.4

Sales Problem (Flowchart)‏

Sales Problem (Pseudocode)‏

Sales Problem (Pseudocode) cont.

Sales Problem (Visual Basic— Screen 2)‏

Sales Problem (Visual Basic— Screen 3)‏

Enrichment If the user clicked the Compute Commission a message box will display information to the user.

Sales Problem (Visual Basic— Screen 4)‏

Sales Problem (Visual Basic— btnCompute_Click)‏

Sales Problem (Visual Basic— btnCompute_Click) cont.

Sales Problem (Visual Basic— btnEnd_Click)‏