FLOWCHART.ppt

March 28, 2018 | Author: Stanley Bennett | Category: Algorithms, Variable (Computer Science), Input/Output, Sales, Data


Comments



Description

School of BusinessEastern Illinois University Program Flowchart, Pseudocode & Algorithm development Week 2: Wednesday 1/22/2003 Friday © Abdou Illia, Spring 2003 1/24/2003 Project 1  Exercise # 8, page 57 Bohl & Rynn’s textbook  Due date: February 3rd, 2003 2 Learning Objectives  Understand the relation between Algorithm and Pseudocode or program flowchart  Draw flowcharts  Write pseudocodes 3 . START READ EMPLOYEE DATA COMPUTE GROSS PAY COMPUTE DEDUCTIONS COMPUTE NET PAY WRITE EMPLOYEE PAYCHECK STOP .4 Recall form Class 2 & 3  Use of tools by analyst/programmer in SDLC  Design/Programming tools used for: – Specifying problem-solving logic Example Pseudocode: English-language statements that describe the processing steps of a program in paragraph form. -. Any algorithm must meet the following requirements: – – Use operations from only a given set of basic operations (+.Algorithm ?  Step-by-step procedure to solve a problem  An algorithm can be expressed using: – – –  5 A System Flowchart A Program Flowchart A Pseudocode.>…) Produce solution in a finite number of such operations .<./.*. etc. Example of algorithm (program flowchart) Algorithm for determining salespersons’ pay REGSALES = Regular sales amount I SALESALES = Reduced sales amount REGCOM = Regular commission (6%) SALESCOM = Sales commission (3%) PAY = Total pay due P O 6 . 7 Algorithm vocabulary SYMBOLS START NAME USE Terminal interrupt symbols Terminal point (start. stop. or break) STOP Input/Output symbol Process symbol Reading data from an input medium or writing data to an output medium Processing input data . 8 Algorithm vocabulary SYMBOLS NAME USE Flowline symbol Sequence of operations and direction of data flow Decision symbol Predefined-process symbol Decision-making operations Operations specified elsewhere (not in the current algorithm) . another part of the Flowchart Preparation symbol Control operations: Set limit on loop-control variables. etc. .9 Algorithm vocabulary SYMBOLS NAME USE Connector symbol Exit to. or entry from. Initialize accumulators. SALESALES Comment 1) Variables names are placeholders for values 2) Variable names are chosen by programmer 3) Names should be descriptive READ $1000. and then.10 Algorithm vocabulary Item Meaning Variables Data items whose values may change. Assignment statement Statement that assign a value (calculated or not) to a variable Constant A value that doesn’t change Example READ REGSALES.06 The computer will perform the calculation first. $3000 REGCOM = REGSALES *. assign the result to REGCOM .06 . or vary during processing Data independence Using Variables instead of their specific values gives a program the capacity to perform processing on any set of input data. … : : .… AMOUNT DISCOUNT = AMOUNT * .10 SUBBIL= AMOUNT SUBBIL = AMOUNT – DISCOUNT Processing 2 : : YES > 200 ? Processing 1 Processing 3 11 Could be many processings.IFTHENELSE / DECISION SYMBOL An Example General form : READ AMOUNT : NO Is Condition True ? NO YES Could be many processings. Full-time students pay a flat rate of $1000 for tuition. The input will contain the student name.Exercise 1: Tuition bill Problem 12 Write the program flowchart to prepare a tuition bill. and computed tuition. The bill will contain the student name. Exercise 11 (Chapter 3) . and total number of credits for which the student has enrolled. Total credits of 10 or more indicate that the student is full-time. Social Security Number. Total credits of less than 10 indicate that the student is part-time. Social Security Number. Part-time students pay $100 per credit for tuition. (To be done in class) 13 Exercise 1’s solution: (Part 1: System Flowchart) . (To be done in class) 14 Exercise 1 solution: (Part 2: Program Flowchart) . Output the student name and an S (Success) if the average of the three grades is 65 or more. and three grades. . output the student’s name. student number.Project 1 15 Write a program flowchart and corresponding pseudocode to solve the following problem: Assume the input for a student is name. a U (Unsuccess). Otherwise (else). and the number of additional points needed for an S. 99 AMTOD DISCOUNT SUBBILL TAXES BILL . NAME Mrs. assuming the values shown below are read as input for the first four variables named. Wallace ITEM Blouse QTY 3 PRICE 49. and answer the following questions: (a) For what variables are values read as input ? (b) What variables’ values are output ? (c) What constants are used ? (d) Simulate the execution of this algorithm. A. B.Exercise 2: Billing problem 16 Exercise 11 (Chapter 2) Look at the program flowchart on the next slide. Exercise 2: Billing problem Exercise 11 (Chapter 2) START READ NAME. QTY. ITEM. BILL STOP 17 . PRICE AMTOD = QTY * PRICE DISCOUNT = AMTOD * .DISCOUNT TAXES = SUBBILL * .10 SUBBILL = AMTOD . ITEM.05 BILL = SUBBILL + TAXES WRITE NAME. TUITION Stop STOP . SSN.Exercise 1 solution: Program Flowchart & corresponding Pseudocode 18 START READ NAME. TUITION ENDIF Write NAME. SSN. SSN. CREDITS NO CREDITS Pseudocode for Tuition problem Start YES ≥ 10 ? Read NAME. CREDITS IF CREDITS >= 10 THEN TUITION = TUITION = 1000 TUITION = 1000 100 * CREDITS ELSE TUITION = 100 * CREDITS WRITE NAME. SSN. SSN. SSN. CREDITS IF CREDITS >= 10 THEN UPPERCASE for variable names TUITION = 1000 ELSE TUITION = 100 * CREDITS UPPERCASE for Reserved words ENDIF Write NAME.reserved words Stop . TUITION Titlecase Lowercase for non.19 Pseudocode  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.e. CREDITS IF CREDITS >= 10 THEN Use of indentation (i. TUITION Stop . SSN. clauses are indented a few positions) for clarity TUITION = 1000 ELSE TUITION = 100 * CREDITS ENDIF Write NAME.20 Pseudocode Pseudocode for Tuition problem (see Slide12) Start Read NAME. and pay. (For example. number. Output is the salesperson’s name. Use a DOWHILE loop and a counter to compute the weekly payroll for exactly 20 employees. . 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.15 * 100] = $350). Any sales over $500 merit a 15% commission for the employee.10 * 500] + $15 [. and weekly sales. Input to the program is a salesperson’s name. if sales = $600. then pay = $300 + $50 [or . number.Exercise 3: Weekly Payroll problem 21 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. NUM. SALES WEEKLY PAYROLL PROGRAM NAME. PAY .22 Exercise 3’s solution: (Part 1: System Flowchart) NAME. NUM. (To be done in class) 23 Exercise 3 solution: (Part 2: Program Flowchart) . Exercise 3 solution: (Part 3: Pseudocode) (To be done in class) 24 . extreme values. . in order to: – –  Prevent errors from occurring Detect and correct errors soon Selection of Review Team members for: – –  25 Informal design review or Structured design review Structured Design Review: – – Selection of representative values of input (data normally expected.Algorithm Development Process  Design verification. invalid data) Following designed algorithms to determine what output are produce. 3 above & Exercise 15 Ch. and Program flowchart and Pseudocode on the other hand. Discuss the relations between the two. 2.2. You should know how to design program logic using Program Flowcharts & Pseudocodes (Review Exercises 1.4 and answer on page 339) 26 .Summary Questions 1. Distinguish between Algorithm on the one hand. (b) What control structures they represent. (a) List the main keywords used in Pseudocodes.
Copyright © 2024 DOKUMEN.SITE Inc.