OSU ENGR H192 - Structured Engineering Problem Solving and Logic Diagrams

Unformatted text preview:

Structured Engineering Problem Solving and Logic DiagramsTOOLS FOR PROGRAM DEVELOPMENTSlide 3TOP-DOWN STEPWISE REFINEMENTSlide 5Top-Down ExampleTop-Down Example (continued)Slide 8Slide 9Slide 10Slide 11Slide 12Handling Special CasesSlide 14Some Types of Logic DiagramsCharacteristics of Flow ChartsFlow Charting SymbolsSlide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Lect 3 P. 1 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionStructured Engineering Problem Solving and Logic DiagramsLecture 3Lect 3 P. 2 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTOOLS FOR PROGRAM DEVELOPMENT•A variety of tools and techniques can be used in the process of program development•Useful for organizing the tasks in problem solving•Many of the tools are focused on the:–development or formulation of algorithms–representation of algorithms–refinement or structuring of algorithmsLect 3 P. 3 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTOOLS FOR PROGRAM DEVELOPMENT•Top-down design technique –Start with overall function and perform several step-wise refinements•Pseudo code–Artificial and informal language that helps programmers develop algorithms•Logic diagrams–Alternate representations of algorithms including graphic and state representationsLect 3 P. 4 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTOP-DOWN STEPWISE REFINEMENT•Begin with a single statement that conveys the overall function of the program. This is a complete (but simple) representation of the program.•Divide this "top" statement into a series of smaller tasks and list them in the order in which they must be performed to produce a first refinement.Lect 3 P. 5 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTOP-DOWN STEPWISE REFINEMENT•Next, refine each of the smaller tasks into yet smaller steps, defining specific "variables" as may be needed in this second refinement.•Continue refinement until algorithm is fully developed.•When combined with pseudo code, writing the program is normally straightforward.Lect 3 P. 6 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example•The Problem:The students in a class have taken their first quiz. The grades (in the range of 0 to 100) are available. Determine the class average on the quiz.•Givens:Grades, Possible range of legitimate grades.Lect 3 P. 7 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)•Unknowns:How many grades to be averaged?•Assumptions:A "grade" not in the range of expected grades could be used to indicate the that all of the legitimate grades have been entered. (Called "sentinel" or "flag".)Lect 3 P. 8 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)•Using pseudo code, we begin by representing the top:–Determine the class average for the quizLect 3 P. 9 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)•Next, perform the first refinement:–Determine the class average for the quiz•Initialize variables•Input, sum, and count quiz grades•Calculate and print the class averageLect 3 P. 10 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)•Next, refine each one of these smaller tasks:–Initialize variables•Initialize a running total to zero•Initialize a grade counter to zeroLect 3 P. 11 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)Input, sum, and count quiz gradesInput the first gradeWhile the user has not entered the "flag"Add this grade into the running totalAdd one to the grade counterInput next grade (possibly the "flag")Lect 3 P. 12 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionTop-Down Example (continued)Calculate and print the class averageIf the grade counter is not zeroSet the class average to the running total divided by the grade counterPrint the averageElsePrint "No grades were entered"Lect 3 P. 13 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionHandling Special Cases•Notice that the top-down refinement example included the handling of a "special case".•Many of you are aware of the special treatment that Windows gives to the extreme "special cases" (sometimes called the BSOD or Blue Screen of Death…)Lect 3 P. 14 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionHandling Special CasesLect 3 P. 15 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionSome Types of Logic Diagrams•Flow Charts -- graphic representation of an algorithm–an aid to writing the program–no formal standards, but common guidelines•Action Diagrams -- technique for diagramming of control structures of a program–an outline of the computer application–what things happen, when, where, how many timesLect 3 P. 16 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionCharacteristics of Flow Charts•Useful tool in program development•Not a complete description of program•Not only tool to use•Made before writing the program•Program might differ from flowchart•Only executable statements are shown•Specific equations and tests not included•Every main and sub-program is chartedLect 3 P. 17 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionFlow Charting Symbols•The commonly used flowcharting symbols follow•Refer to Section 9 of the H192 "Class Notes" for a more complete description of the


View Full Document

OSU ENGR H192 - Structured Engineering Problem Solving and Logic Diagrams

Documents in this Course
Strings

Strings

22 pages

Load more
Download Structured Engineering Problem Solving and Logic Diagrams
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Structured Engineering Problem Solving and Logic Diagrams and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Structured Engineering Problem Solving and Logic Diagrams 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?