Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.

Slides:



Advertisements
Similar presentations
Chapter 3: Modularization
Advertisements

Programming Logic and Design Fourth Edition, Introductory
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 1 - An Introduction to Computers and Problem Solving
Introduction to Programming
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
Chapter 2- Visual Basic Schneider
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 2: Input, Processing, and Output
Modules, Hierarchy Charts, and Documentation
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 3 Planning Your Solution
The Program Design Phases
An Overview of Computers and Programming
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
© Paradigm Publishing Inc Chapter 12 Programming Concepts and Languages.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction 01_intro.ppt
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
Simple Program Design Third Edition A Step-by-Step Approach
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Technology in Action Alan Evans Kendall Martin Mary Anne Poatsy Twelfth Edition.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
Programming Concepts Chapter 3.
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.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Cs413_design04.ppt Design and Software Development Design : to create a functional interface that has high usability Development : an organized approach.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
1 Program Planning and Design Important stages before actual program is written.
Chapter 14 Programming and Languages McGraw-Hill/Irwin Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved.
Programming and Languages Dept. of Computer and Information Science IUPUI.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
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.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Algorithms and Flowcharts
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
Chapter 2: Input, Processing, and Output
Chapter 2- Visual Basic Schneider
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.
Algorithm and Ambiguity
An Introduction to Visual Basic .NET and Program Design
Designing and Debugging Batch and Interactive COBOL Programs
Problem Solving Techniques
VISUAL BASIC – CHAPTER ONE NOTES An Introduction to Visual Basic
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
ICT Gaming Lesson 2.
Chapter 2: Input, Processing, and Output
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing a Program

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved The Program Development Cycle Problem solving principles –Completely understand the problem –Devise a plan to solve it –Carry out the plan –Review the results Writing a program –1) Analyze the problem –2) Design the program –3) Code the program –4) Test the program

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 3 1) Analyze the Problem Example –The problem: A local department store needs to develop a program which, when given an items original price and the percentage it has been discounted will compute the total price( including sales tax) of items that have been placed on sale. What are the inputs? (given data) What are the outputs? (required data) How will we calculate the required outputs from the given inputs?

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved Program Design Modular programming –Determine the major tasks that the program must accomplish. Each of these tasks will be a module. –Some modules will be complex themselves, and they will be broken into submodules, and those submodules may also be broken into even smaller modules. –This is called top-down design

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 5 The first illustration of top down design describes the 3 fundamental tasks that are required in the Brewster example: –Input –Perform Calculations (Process) –Output Input Perform Calculations Output Input variables:AmountSaved=OriginalPrice*Discount rate/100 Display ItemNameSalePrice=OrigialPrice-AmountSaved TotalPrice DiscountRate Tax=SalePrice*.065 OriginalPriceTotalPrice=SalePrice+Tax

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 6 A Code Module Performs a single task Is self-contained and independent of other modules Relatively short – less than 1 page Calling module Called module Transfer of control Main is the controller of all sub-modules

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 7 Hierarchy Chart Like an organization chart – shows position of modules in the program. Depicts what modules exist and how they are related. Large programs need a “map” for documentation. One page of code per module – keeps the program manageable. We will have very small modules while getting comfortable using these tools.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 8 Hierarch Chart for Example Main Module Input Data Perform Calculations Output Results

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved Coding, Documenting, and Testing Coding –done in a specific programming language. We will use pseudocode. –should only begin after a solid design exists. Documenting –Code needs to contain documentation that describes to the reader what the code is doing – called comments –This kind of documentation is for the programmers to read –There is also User Documentation that is external to the code and may take the form of a User’s Guide

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 10 Testing –Create test data that will be used to check the program’s correctness. For example, if the following test data is used, does the program generate the expected results? (Determine the expected results before the code is written.) Item Name =Beach Ball Price =60 Discount Percentage=20 If a Desk check of the code gets the same answer as the expected results then the code has been tested, and is likely correct.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 11 Types of Errors Syntax – wrong grammar, i.e., breaking the rules of how to write the language –Forgetting punctuation, misspelling keyword –The program will not run at all with syntax errors Logic - the program runs, but does not produce the expected results. –Using an incorrect formula, incorrect sequence of statements, etc. –These errors are detected during the desk-check, of the program; an important part of the cycle.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved Structured Programming A method for designing and coding programs in a systematic, organized manner. It combines the principles of top-down design, modularity and the use of the three accepted control structures of sequence, repetition and selection. Sequence, repetition and selection can be expressed in pseudocode, or with Flowcharts

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 13 Flowcharts Another tool for programmers to design programs –Describe the flow of a program module’s execution with diagrams. –(Completely different from hierarchy charts). –Connected symbols are used to describe sequence, repetition, and selection. –Some prefer to use flow charting to learn how to express algorithms, and others prefer to use pseudocode.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 14 Control Structures SequenceSequence –in sequential order. –The simplest of control structures – start at the beginning and continue in sequential order. RepetitionRepetition – repeat statements more than once –Called a loop, it needs a stop condition, I.e, the program will continue to loop until some condition is met. SelectionSelection – selectively execute statements –Called a branch, it requires a condition to determine when to execute statements.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved An Introduction to GUIs and OOP GUI – Graphical User Interface –Users interact with software using a mouse, to select from menu choices, clicking on buttons, etc. –Development of GUI software uses tools specifically designed for that task. –Event-driven programming is the development of software where the flow of control is based on the user’s clicking on menus and buttons, etc. These user actions are called events. Event-driven programming still uses the basic principles of structured programming – program modules, control structures, good programming style, and program testing.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 16 Object-oriented Programming Focus is on the objects that will be used to solve the problems. Object – a structure that contains attributes and methods (data and process) Object-oriented Design starts with identifying the required objects. Java, C++, SmallTalk are languages based on Object-oriented programming

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 17 Importance of Structured Programming Structured, Event-driven, and Object-oriented programming techniques are not separate form each other. All require the basic principles of structured programming – program modules, control structures, good programming style, and program testing.

Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 18 Pseudocode Language (Ch 2) In this chapter we added a way to create and call modules in our programs. InputAssignment Input Variable Set Variable = 10 Set Variable = AnotherVariable OutputArithmetic Operations Write “literal text”( ) ^ * / + - Write Variable Write “literal text”, Variable Create a module Call a sub-module ModuleName Call ModuleName …. End