Program Flowchart, Pseudocode & Algorithm development

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

Chapter 2: Problem Solving
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Introduction to Flowcharting
Programming Logic and Design Sixth Edition
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Subject: Information Technology Grade: 10
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
ITEC113 Algorithms and Programming Techniques
Chapter 2- Visual Basic Schneider
Flowcharts and programming Techniques
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 3 Planning Your Solution
The Program Design Phases
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
The University of Texas – Pan American
Chapter 2: Problem Solving
Chapter 2: Problem Solving
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Introduction to Programming Design School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week1, Wednesday 01/15/2003)
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
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.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
ALGORITHM List of instructions for carrying out some process step by step. A sequence of instructions which has a clear meaning and can performed with.
1 Program Planning and Design Important stages before actual program is written.
Pseudocode An Introduction. Flowcharts were the first design tool to be widely used, but unfortunately they do not reflect some of the concepts of structured.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Computer Programming TCP1224 Chapter 5 The Selection Structure.
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
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.
An Introduction to Programming with C++ Sixth Edition
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Algorithms and Pseudocode
FLOWCHARTING AND ALGORITHMS
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
Decision Tables and Pseudocode
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
ALGORITHMS AND FLOWCHARTS
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Chapter 2- Visual Basic Schneider
Algorithms and Flowcharts
Chapter 5: Control 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.
Introduction to Computer Programming
ALGORITHMS AND FLOWCHARTS
Designing and Debugging Batch and Interactive COBOL Programs
Pseudocode An Introduction
MSIS 655 Advanced Business Applications Programming
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
Programming Logic and Design Fifth Edition, Comprehensive
Pseudocode For Program Design.
Presentation transcript:

Program Flowchart, Pseudocode & Algorithm development School of Business Eastern Illinois University Program Flowchart, Pseudocode & Algorithm development Week 2: Wednesday 1/22/2003 Friday 1/24/2003 © Abdou Illia, Spring 2003

Project 1 Exercise # 8, page 57 Bohl & Rynn’s textbook Due date: February 3rd, 2003

Learning Objectives Understand the relation between Algorithm and Pseudocode or program flowchart Draw flowcharts Write pseudocodes

Recall form Class 2 & 3 Use of tools by analyst/programmer in SDLC Design/Programming tools used for: Specifying problem-solving logic START READ EMPLOYEE DATA COMPUTE GROSS PAY COMPUTE DEDUCTIONS COMPUTE NET PAY WRITE EMPLOYEE PAYCHECK STOP Example Pseudocode: English-language statements that describe the processing steps of a program in paragraph form.

Algorithm ? Step-by-step procedure to solve a problem An algorithm can be expressed using: A System Flowchart A Program Flowchart A Pseudocode, etc. Any algorithm must meet the following requirements: Use operations from only a given set of basic operations (+,-,/,*,<,>…) Produce solution in a finite number of such operations

Example of algorithm (program flowchart) Algorithm for determining salespersons’ pay I REGSALES = Regular sales amount SALESALES = Reduced sales amount REGCOM = Regular commission (6%) SALESCOM = Sales commission (3%) PAY = Total pay due P O

Algorithm vocabulary SYMBOLS NAME USE START STOP Terminal interrupt symbols Terminal point (start, stop, or break) STOP Reading data from an input medium or writing data to an output medium Input/Output symbol Process symbol Processing input data

Algorithm vocabulary SYMBOLS NAME USE Flowline symbol Sequence of operations and direction of data flow Decision symbol Decision-making operations Predefined-process symbol Operations specified elsewhere (not in the current algorithm)

Algorithm vocabulary SYMBOLS NAME USE Connector symbol Exit to, or entry from, another part of the Flowchart Preparation symbol Control operations: Set limit on loop-control variables, Initialize accumulators, etc.

Algorithm vocabulary Item Meaning Example Comment Variables 1) Variables names are place-holders for values 2) Variable names are chosen by programmer 3) Names should be descriptive Data items whose values may change, or vary during processing Variables READ REGSALES, SALESALES Using Variables instead of their specific values gives a program the capacity to perform processing on any set of input data. Data independence READ $1000, $3000 Assignment statement Statement that assign a value (calculated or not) to a variable The computer will perform the calculation first, and then, assign the result to REGCOM REGCOM = REGSALES *.06 Constant A value that doesn’t change .06

IFTHENELSE / DECISION SYMBOL General form An Example : READ AMOUNT Is Condition True ? AMOUNT > 200 ? NO YES NO YES Processing 1 DISCOUNT = AMOUNT * .10 Processing 3 SUBBIL= AMOUNT Could be many processings,… Processing 2 SUBBIL = AMOUNT – DISCOUNT Could be many processings,… : :

Exercise 1: Tuition bill Problem Write the program flowchart to prepare a tuition bill. The input will contain the student name, Social Security Number, and total number of credits for which the student has enrolled. The bill will contain the student name, Social Security Number, and computed tuition. Total credits of 10 or more indicate that the student is full-time. Full-time students pay a flat rate of $1000 for tuition. Total credits of less than 10 indicate that the student is part-time. Part-time students pay $100 per credit for tuition. Exercise 11 (Chapter 3)

Exercise 1’s solution: (Part 1: System Flowchart) (To be done in class)

Exercise 1 solution: (Part 2: Program Flowchart) (To be done in class)

Project 1 Write a program flowchart and corresponding pseudocode to solve the following problem: Assume the input for a student is name, student number, and three grades. Output the student name and an S (Success) if the average of the three grades is 65 or more. Otherwise (else), output the student’s name, a U (Unsuccess), and the number of additional points needed for an S.

Exercise 2: Billing problem Exercise 11 (Chapter 2) Look at the program flowchart on the next slide, and answer the following questions: For what variables are values read as input ? What variables’ values are output ? What constants are used ? Simulate the execution of this algorithm, assuming the values shown below are read as input for the first four variables named. NAME Mrs. A. B. Wallace ITEM Blouse QTY 3 PRICE 49.99 AMTOD DISCOUNT SUBBILL TAXES BILL

Exercise 2: Billing problem Exercise 11 (Chapter 2) START READ NAME, ITEM, QTY, PRICE AMTOD = QTY * PRICE DISCOUNT = AMTOD * .10 SUBBILL = AMTOD - DISCOUNT TAXES = SUBBILL * .05 BILL = SUBBILL + TAXES WRITE NAME, ITEM, BILL STOP

Exercise 1 solution: Program Flowchart & corresponding Pseudocode START READ NAME, SSN, CREDITS Pseudocode for Tuition problem Start Read NAME, SSN, CREDITS IF CREDITS >= 10 THEN TUITION = 1000 ELSE TUITION = 100 * CREDITS ENDIF Write NAME, SSN, TUITION Stop CREDITS ≥ 10 ? NO YES TUITION = 100 * CREDITS TUITION = 1000 WRITE NAME, SSN, TUITION STOP

Pseudocode for Tuition problem (see Slide12) Other common way to represent algorithms Similar to programming languages like Visual Basic but Does not require strict rules as programming languages Pseudocode for Tuition problem (see Slide12) Start Read NAME, SSN, CREDITS IF CREDITS >= 10 THEN TUITION = 1000 ELSE TUITION = 100 * CREDITS ENDIF Write NAME, SSN, TUITION Stop UPPERCASE for variable names UPPERCASE for Reserved words Titlecase Lowercase for non- reserved words

Pseudocode for Tuition problem (see Slide12) Start Read NAME, SSN, CREDITS IF CREDITS >= 10 THEN TUITION = 1000 ELSE TUITION = 100 * CREDITS ENDIF Write NAME, SSN, TUITION Stop Use of indentation (i.e. clauses are indented a few positions) for clarity

Exercise 3: Weekly Payroll problem Exercise 19 (Chapter 4) Construct a program flowchart and corresponding pseudocode to solve the following problem: ABC company needs a weekly payroll report for its salespeople. Input to the program is a salesperson’s name, number, and weekly sales. Output is the salesperson’s name, number, and pay. Each salesperson receives a base pay of $300 as well as a 10% commission on his or her total sales up to and including $500. Any sales over $500 merit a 15% commission for the employee. (For example, if sales = $600, then pay = $300 + $50 [or .10 * 500] + $15 [.15 * 100] = $350). Use a DOWHILE loop and a counter to compute the weekly payroll for exactly 20 employees.

Exercise 3’s solution: (Part 1: System Flowchart) NAME, NUM, SALES WEEKLY PAYROLL PROGRAM NAME, NUM, PAY

Exercise 3 solution: (Part 2: Program Flowchart) (To be done in class)

Exercise 3 solution: (Part 3: Pseudocode) (To be done in class)

Algorithm Development Process Design verification, in order to: Prevent errors from occurring Detect and correct errors soon Selection of Review Team members for: Informal design review or Structured design review Structured Design Review: Selection of representative values of input (data normally expected, extreme values, invalid data) Following designed algorithms to determine what output are produce.

Summary Questions 1. Distinguish between Algorithm on the one hand, and Program flowchart and Pseudocode on the other hand. Discuss the relations between the two. 2. (a) List the main keywords used in Pseudocodes. (b) What control structures they represent. You should know how to design program logic using Program Flowcharts & Pseudocodes (Review Exercises 1,2,3 above & Exercise 15 Ch.4 and answer on page 339)