Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering Problem Solving and Logic.

Slides:



Advertisements
Similar presentations
PROBLEM SOLVING TECHNIQUES
Advertisements

 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
1.4 Programming Tools Flowcharts Pseudocode Hierarchy Chart
UNIT 2. Introduction to Computer Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Fundamentals of Algorithms MCS - 2 Lecture # 4
 Control structures  Algorithm & flowchart  If statements  While statements.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter4: Control Statements Part I.
Chapter 2- Visual Basic Schneider
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Chapter 3 - Structured Program Development
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Introduction to Computers and Programming Lecture 8: More Loops New York University.
Introduction to Computers and Programming More Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Structured Program Development in C
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
Lecture 3 Structured Program Development in C
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Review Algorithm Analysis Problem Solving Space Complexity
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering.
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
The University of Texas – Pan American
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
ENG 1181 College of Engineering Engineering Education Innovation Center P. 1 1 Computer Problem Solving in MATLAB Topics Covered: 1.Problem Solving 2.Top-Down.
Software Life Cycle What Requirements Gathering, Problem definition
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
C Lecture Notes 1 Structured Program Development.
Chapter 3 - Structured Program Development Outline 3.1Introduction 3.2Algorithms 3.3Pseudocode 3.4Control Structures 3.5The If Selection Structure 3.6The.
Visual Basic Programming
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Unit 2 – Algorithms & Pseudocode. Algorithms Computer problems solved by executing series of action in order Procedure –The Actions to execute –The Order.
Structured Program Development Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010.
Basic problem solving CSC 111.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 1.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
The Hashemite University Computer Engineering Department
Top-Down Stepwise Refinement (L11) * Top-Down Stepwise Refinement * Cast Operator * Promotion (Implicit Conversion) * Unary Operator * Multiplicative Operator.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (while) Outline 3.7The While Repetition.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 23, 2005 Lecture Number: 11.
Algorithm: procedure in terms of
Chapter 2- Visual Basic Schneider
Chapter 4 – Control Structures Part 1
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
MSIS 655 Advanced Business Applications Programming
Structured Program
Chapter 3 - Structured Program Development
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
Chapter 3 - Structured Program Development
Chapter 2- Visual Basic Schneider
EPSII 59:006 Spring 2004.
Basic Concepts of Algorithm
Presentation transcript:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 1Winter Quarter Structured Engineering Problem Solving and Logic Diagrams Lecture 3

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 2Winter Quarter TOOLS 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 algorithms

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 3Winter Quarter TOOLS 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 representations

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 4Winter Quarter TOP-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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 5Winter Quarter TOP-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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 6Winter Quarter Top-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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 7Winter Quarter Top-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".)

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 8Winter Quarter Top-Down Example (continued) Using pseudo code, we begin by representing the top: –Determine the class average for the quiz

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 9Winter Quarter Top-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 average

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 10Winter Quarter Top-Down Example (continued) Next, refine each one of these smaller tasks: –Initialize variables Initialize a running total to zero Initialize a grade counter to zero

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 11Winter Quarter Top-Down Example (continued) Input, sum, and count quiz grades Input the first grade While the user has not entered the "flag" Add this grade into the running total Add one to the grade counter Input next grade (possibly the "flag")

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 12Winter Quarter Top-Down Example (continued) Calculate and print the class average If the grade counter is not zero Set the class average to the running total divided by the grade counter Print the average Else Print "No grades were entered"

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 13Winter Quarter Handling 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…)

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 14Winter Quarter Handling Special Cases

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 15Winter Quarter Some 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 times

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 16Winter Quarter Characteristics 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 charted

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 17Winter Quarter Flow Charting Symbols The commonly used flowcharting symbols follow Refer to Section 9 of the H192 "Class Notes" for a more complete description of the various flowcharting symbols normally used

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 18Winter Quarter Flow Charting Symbols Begin or End a Procedure: "Main Program" "Subprogram" Begin End

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 19Winter Quarter Flow Charting Symbols Write to Screen: Read from Keyboard:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 20Winter Quarter Flow Charting Symbols Read from a File: Read from a File with a Check for End-of-File:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 21Winter Quarter Flow Charting Symbols Decision or Selection Structure: General Processing:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 22Winter Quarter Flow Charting Symbols Definite Loop: Indefinite Loop:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 23Winter Quarter Flow Charting Symbols On-Page Connectors: Off-Page Connectors:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 24Winter Quarter Flow Charting Symbols Call (or Invoke) a Subprogram:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 25Winter Quarter Daily Assignment E2 Problem: There are a number of apples in a large box which must be sorted into baskets. An apple is either a "large red" one, a "small red" one, or a "green" one.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 3P. 26Winter Quarter Daily Assignment E2 Assumptions: 1.There are 3 empty baskets present and they are labeled: #1 – large red, #2 – small red, #3 – green 2.There are counters of some sort present. 3.The person sorting is not color blind and can tell the difference between large and small apples. 4.Only these three kinds of apples are in the large box.