FLOWCHART.ppt

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

Transcript of FLOWCHART.ppt

  • Program Flowchart, Pseudocode & Algorithm developmentSchool of BusinessEastern Illinois University Abdou Illia, Spring 2003Week 2:Wednesday 1/22/2003Friday 1/24/2003

  • *Project 1Exercise # 8, page 57Bohl & Rynns textbook

    Due date: February 3rd, 2003

  • *Learning ObjectivesUnderstand the relation between Algorithm and Pseudocode or program flowchartDraw flowchartsWrite pseudocodes

  • *Recall form Class 2 & 3Use of tools by analyst/programmer in SDLCDesign/Programming tools used for:Specifying problem-solving logic Pseudocode:English-language statements that describe the processing steps of a program in paragraph form.

  • *Algorithm ?Step-by-step procedure to solve a problemAn algorithm can be expressed using:A System FlowchartA Program FlowchartA 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)REGSALES = Regular sales amountSALESALES = Reduced sales amountREGCOM = Regular commission (6%)SALESCOM = Sales commission (3%)PAY = Total pay dueAlgorithm for determining salespersons payIPO

  • *Algorithm vocabularySTARTSTOPSYMBOLSNAMETerminal interrupt symbolsUSETerminal point (start, stop, or break)Input/Output symbolReading data from an input medium or writing data to an output mediumProcess symbolProcessing input data

  • *Algorithm vocabularySYMBOLSNAMEFlowline symbolUSESequence of operations and direction of data flowDecision symbolDecision-making operationsPredefined-process symbolOperations specified elsewhere (not in the current algorithm)

  • *Algorithm vocabularySYMBOLSNAMEConnector symbolUSEExit to, or entry from, another part of the FlowchartPreparation symbolControl operations: Set limit on loop-control variables, Initialize accumulators, etc.

  • *Algorithm vocabularyVariables Data independence Assignment statement Constant Data items whose values may change, or vary during processing Using Variables instead of their specific values gives a program the capacity to perform processing on any set of input data. Statement that assign a value (calculated or not) to a variable A value that doesnt change

    REGCOM =REGSALES*.06READREGSALES,SALESALESREAD$1000,$3000.061) Variables names are place-holders for values2) Variable names are chosen by programmer3) Names should be descriptive The computer will perform the calculation first, and then, assign the result to REGCOM

    ItemMeaningExampleComment

  • *IFTHENELSE / DECISION SYMBOLIs Condition True ?Processing 1Processing 2Processing 3::::General formAMOUNT> 200 ?DISCOUNT =AMOUNT * .10SUBBIL =AMOUNT DISCOUNTSUBBIL=AMOUNT::An ExampleREADAMOUNTYESNOYESNOCould be many processings,Could be many processings,

  • *Exercise 1: Tuition bill ProblemWrite 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 1s solution: (Part 1: System Flowchart)(To be done in class)

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

  • *Project 1Write 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 students name, a U (Unsuccess), and the number of additional points needed for an S.

  • *Exercise 2: Billing problemLook 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.Exercise 11 (Chapter 2)Blouse349.99Mrs. A. B. WallaceITEMQTYPRICEAMTODDISCOUNTNAMESUBBILLTAXESBILL

  • *Exercise 2: Billing problemExercise 11 (Chapter 2)STARTREAD NAME, ITEM, QTY, PRICEAMTOD = QTY * PRICEDISCOUNT = AMTOD * .10SUBBILL = AMTOD - DISCOUNTTAXES =SUBBILL * .05BILL = SUBBILL + TAXESWRITE NAME, ITEM, BILLSTOP

  • *Exercise 1 solution: Program Flowchart & corresponding PseudocodeREAD NAME, SSN, CREDITSWRITE NAME, SSN, TUITIONCREDITS 10 ?TUITION = 1000TUITION = 100 * CREDITSSTARTSTOPStartRead NAME, SSN, CREDITSIF CREDITS >= 10 THENTUITION = 1000ELSETUITION = 100 * CREDITSENDIFWrite NAME, SSN, TUITIONStopPseudocode for Tuition problemNOYES

  • *PseudocodeOther common way to represent algorithmsSimilar to programming languages like Visual Basic butDoes not require strict rules as programming languagesStartRead NAME, SSN, CREDITSIF CREDITS >= 10 THENTUITION = 1000ELSETUITION = 100 * CREDITSENDIFWrite NAME, SSN, TUITIONStopPseudocode for Tuition problem (see Slide12)UPPERCASE for variable namesUPPERCASE for Reserved wordsLowercase for non- reserved wordsTitlecase

  • *PseudocodeStartRead NAME, SSN, CREDITSIF CREDITS >= 10 THENTUITION = 1000ELSETUITION = 100 * CREDITSENDIFWrite NAME, SSN, TUITIONStopPseudocode for Tuition problem (see Slide12)Use of indentation (i.e. clauses are indented a few positions) for clarity

  • *Exercise 3: Weekly Payroll problemConstruct 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 salespersons name, number, and weekly sales. Output is the salespersons 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 19 (Chapter 4)

  • *Exercise 3s solution: (Part 1: System Flowchart)NAME, NUM, SALESWEEKLY PAYROLL PROGRAMNAME, 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 ProcessDesign verification, in order to:Prevent errors from occurringDetect and correct errors soonSelection of Review Team members for:Informal design review orStructured design reviewStructured 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 Questions1. 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)