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

Slides:



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

Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Selection control structures
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
Program Design and Development
Chapter 2: Input, Processing, and Output
Modules, Hierarchy Charts, and Documentation
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
General Algorithms for Common Business Problems
Chapter 1 Program Design
CHAPTER 6 FILE PROCESSING. 2 Introduction  The most convenient way to process involving large data sets is to store them into a file for later processing.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Control Statements.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Chapter 3 Planning Your Solution
Adding Automated Functionality to Office Applications.
DCT 1123 Problem Solving & Algorithms
The Software Development Cycle Defining and understanding the problem.
Chapter 9 Describing Process Specifications and Structured Decisions
Lecture Set 5 Control Structures Part A - Decisions Structures.
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
Problem Solving with Decisions
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
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.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
13-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Sequential Files Chapter 13. Master Files Set of files used to store companies data in areas like payroll, inventory Set of files used to store companies.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
General Algorithms for Common Business Problems Simple Program Design Third Edition A Step-by-Step Approach 10.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Programming with Microsoft Visual Basic th Edition
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
1 Program Planning and Design Important stages before actual program is written.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
DOWHILE: Trailer Record Logic
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
Master File Update Processing. Objectives On completing this section you should be able to: w Distinguish between online processing and batch processing.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
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?
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Array Applications. Objectives Design an algorithm to load values into a table. Design an algorithm that searches a table using a sequential search. Design.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
An Introduction to Programming with C++1 More on the Selection Structure Tutorial 7.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
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.
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Chapter 7 JavaScript: Control Statements, Part 1
Chapter 8: More on the Repetition Structure
The Selection Structure
Chapter 3 Control Statements Lecturer: Mrs Rohani Hassan
Designing and Debugging Batch and Interactive COBOL Programs
Please use speaker notes for additional information!
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
CHAPTER 17 The Report Writer Module
Flowcharts and Pseudo Code
Chapter 2: Input, Processing, and Output
Chapter 4: Writing and Designing a Complete Program
Presentation transcript:

Chapter 7 CASE 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 We must provide flexibility in a solution algorithm, incorporating within the program an ability to process not only a variable number of inputs but also whatever type of input is provided.  In business applications, large numbers of records are kept for reference purposes as relatively permanent data.  Transaction file or detail file Current activities, or transactions, to be process against the master file.

Inventory Control Example Inventory-control stock status records of the numbers of various part types available for manufacturing planning.  A transaction file is a temporary file containing data that is used to up date a master file.

Inventory Control Example

Master File Update Using Nested IFs (Partial Flowchart)‏

Master File Update Using Nested IFs (Partial Pseudocode)‏

Inventory Control Example Solution 1: Nested IFTHENELSE Control Structure  IFTHENELSE We have to make four test, which amounts to a nesting level of four.

Inventory Control Example Solution 2: CASE Control Structure  CASE control structure generalizes the basic IFTHENELSE pattern, extending it from a two- valued operation to a multiple-valued one.  CASE control structure serves as an alternative for the nested IFTHENELSE, it cannot be used in place of a sequential IFTHENELSE pattern.  Do not confuse CASE with computer-assisted software engineering.  CASE is simply the name of a particular kind of control structure.

Master File Update Using CASE (Partial Flowchart)‏

Master File Update Using CASE (Partial Flowchart) cont.

Inventory Control Example For processing efficiency, the test most likely to reveal a true outcome should be made first, the next most likely one second, and so on.  Minimize the number of tests actually carried out on any one pass.  Other appears by the last flowline to indicate what processing should occur if none of the preceding conditions is true.

Master File Update Using CASE (Partial Pseudocode)‏

Sample Problem 7.1 Op Code Problem  Design an algorithm to accept three values as input. First input value A (addition), S (subtraction), M (multiplication), or D (division)‏ Other two input values will be numbers. The computer is to perform a computation on the two numbers.

Sample Problem 7.1  A single variable cannot be named to represent both numeric quantities and alphabetic data. Character strings  Alphabetic data values. Character-string constant  Set once and never changes during program execution.  A value that is input during processing, is a character string, but it is not a character-string constant.

Op Code Problem (Flowchart)‏

Op Code Problem (Flowchart) cont.

Sales Problem without Modules (Flowchart)‏

Sales Problem without Modules (Flowchart) cont.

Sales Problem without Modules (Pseudocode)‏

Sample Problem 7.3 Sales Problem Using Modules  Place all the steps within each CASE path in a separate.

Sales Problem Using Modules (Structure Chart)‏

Sales Problem Using Modules— Overall Control (Flowchart)‏

Sales Problem Using Modules— Overall Control (Flowchart) cont.

Sales Problem Using Modules— Overall Control (Pseudocode)‏

Sales Problem Using Modules— Process Class 1

Sales Problem Using Modules— Process Class 2

Sales Problem Using Modules— Process Class 3

Sales Problem Using Modules— Process Class 4

Sales Problem Using Modules— Process Invalid Class

Sample Problem 7.4 Sales Problem with Totals  Process several records.  Output a daily sales commission report.  Report and column headings are to be output.  Pages are to be numbered, and up to 55 detail lines.  Five total lines are to be output on the last page of the report.  End-of-file will be indicated by 0000.

Sales Problem with Totals (Structure Chart)‏

Sales Problem with Totals—Overall Control (Flowchart)‏

Sales Problem with Totals—Overall Control (Flowchart) cont.

Sales Problem with Totals—Overall Control (Pseudocode)‏

Sales Problem with Totals—Process Initialization

Sales Problem with Totals—Process a Detail Record (Flowchart)‏

Sales Problem with Totals—Process a Detail Record (Flowchart) cont.

Sales Problem with Totals—Process Detail Record (Pseudocode)‏

Sales Problem with Totals—Process Heading

Sales Problem with Totals—Process Class 1

Sales Problem with Totals—Process Class 2

Sales Problem with Totals—Process Class 3

Sales Problem with Totals—Process Class 4

Sales Problem with Totals—Process Invalid Class

Sales Problem with Totals—Process Totals

Sales Problem with Totals—Process Totals cont.

Enrichment Visual Basic  Graphical interface for the op code problem.

Op Code Problem (Visual Basic— Screen 1)‏

Op Code Problem (Visual Basic— Screen 2)‏

Op Code Problem (Visual Basic— Screen 3)‏

Op Code Problem (Visual Basic— Screen 4)‏

Op Code Problem (Visual Basic— Screen 5)‏

Op Code Problem (Visual Basic— Screen 6)‏

Enrichment SELECT CASE and END SELECT are used in stead of the pseudocode keywords CASENTRY and ENDCASE. ELSE replaces the word other.

Op Code Problem (Visual Basic-- btnComute_Click)‏

Enrichment Another solution to this same problem.

Op Code Problem (Visual Basic— Screen 7)‏

Op Code Problem (Visual Basic— Screen 8)‏

Op Code Problem (Visual Basic— Screen 9)‏

Op Code Problem (Visual Basic— radAdd_Click)‏

Op Code Problem (Visual Basic— radSubtract_Click)‏

Op Code Problem (Visual Basic— radMultiply_Click)‏

Op Code Problem (Visual Basic— radDivide_Click)‏