© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.

Slides:



Advertisements
Similar presentations
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Chapter 2 - Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Chapter 2- Visual Basic Schneider
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 2: Input, Processing, and Output
Chapter 1 Principles of Programming and Software Engineering.
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
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
PRE-PROGRAMMING PHASE
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Chapter 2: Developing a Program Prelude to Programming Concepts and Design Copyright © 2001 Scott/Jones, Inc.. All rights reserved. 1 Chapter 2 Developing.
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
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.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Programming Lifecycle
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
The Software Development Life Cycle. Software Development SDLC The Software Development Life-Cycle Sometimes called the program development lifecycle.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Developing an Algorithm
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
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.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
Programming and Languages Dept. of Computer and Information Science IUPUI.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
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.
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.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Chapter 2- Visual Basic Schneider
Lecture 2 Introduction to Programming
Introduction To Flowcharting
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 Basic CONCEPTS of Basic Concepts of Algorithm
Algorithm and Ambiguity
Computer Programming.
Designing and Debugging Batch and Interactive COBOL Programs
Unit# 9: Computer Program Development
Problem Solving Techniques
Chapter 2- Visual Basic Schneider
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Algorithm and Ambiguity
Software Development Process
ICT Gaming Lesson 2.
Basic Concepts of Algorithm
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Programming Logic and Design Eighth Edition
Presentation transcript:

© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program

1-2 © 2011 Pearson Addison-Wesley. All rights reserved. 1-2 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

1-3 © 2011 Pearson Addison-Wesley. All rights reserved Analyze the Problem Identify desired results (output) Determine input needed to produce those results Example: Create a program to generate 6 numbers to play the lottery –Is 7, 7, 7, 7, 7, 7 ok? –Is -3, 0, 8, 9, 689, 689 ok? –Is 1, 2, 6, , 88, ok? –These are all 6 numbers but we see we must be more specific –Desired results: 6 different positive integers within the range of 1 to 40

1-4 © 2011 Pearson Addison-Wesley. All rights reserved Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step method to solve a problem or complete a task Algorithms must be: –Well defined –Well ordered –Must produce some result –Must terminate in a finite time

1-5 © 2011 Pearson Addison-Wesley. All rights reserved Code the program Translate charts or pseudocode (ordinary language) into program code Add statements to document what the code does –Internal documenation –External documentation Each programming language uses its specific syntax

1-6 © 2011 Pearson Addison-Wesley. All rights reserved. 1-6 What is Syntax? Correct English syntax to tell someone where you put the textbook: I have put it on the table. Correct German syntax for same sentence: I have it on the table put. Each language (spoken or programming) has its own particular rules for its syntax!

1-7 © 2011 Pearson Addison-Wesley. All rights reserved Test the program In analysis phase: continually ask questions –Did I interpret data correctly? –Does program fulfill requirements? –Are my formulas or procedures correct? Etc… In design phase: use desk-checking to walk through the program In coding phase: software will alert you to errors in syntax but not in the logic of the program Finally, test your program with as many sets of test data as possible –Use good data, bad data, data you know the answers for, etc.

1-8 © 2011 Pearson Addison-Wesley. All rights reserved. 1-8 Coding, Documenting, and Testing Coding –Coding is done in a specific programming language. We will use pseudocode. –This phase should only begin after a solid design exists. Documenting –Code needs to contain documentation that describes to the reader what the code is doing –Two types of comments are used within the code –Internal documentation is for the programmers to read –External documentation is for the user

1-9 © 2011 Pearson Addison-Wesley. All rights reserved. 1-9 Types of Errors Syntax errors: a violation of the programming language’s rules for creating valid statements –May be caused by incorrect grammar or punctuation, or misspelling a keyword –The program will not run at all with syntax errors Logic errors: the program runs, but does not produce the expected results –May be caused by using an incorrect formula, or incorrect sequence of statements, etc. –Sometimes called runtime errors –These errors can be detected during the desk checking phase of the programming cycle.

1-10 © 2011 Pearson Addison-Wesley. 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: sequence, repetition and selection Sequence, repetition and selection can be expressed in pseudocode, or with flowcharts

1-11 © 2011 Pearson Addison-Wesley. All rights reserved Flowcharts A tool for programmers to design programs –Describes 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 structures –Some prefer to use flowcharting to learn how to express algorithms, and others prefer to use pseudocode –Many programs are designed with a combination of pseudocode and flowcharts

1-12 © 2011 Pearson Addison-Wesley. All rights reserved Basic flowcharting symbols

1-13 © 2011 Pearson Addison-Wesley. All rights reserved Control Structures In 1960s computer scientists proved there are only 3 basic control structures (also called constructs) needed to create any program or algorithm! Sequence –in sequential order. –The simplest of control structures – start at the beginning and continue in sequential order. Selection – selectively execute statements –Also called a branch or decision –requires a condition to determine when to execute statements. Repetition – repeat statements more than once –Also called a loop –needs a stop condition, i.e, the program will continue to loop until some condition is met.

1-14 © 2011 Pearson Addison-Wesley. All rights reserved. Example: Fahrenheit (F) to Celsius temperature (C) We need to find the Celsius temperature if Fahrenheit is given Formula: C = 5/9*(F-32) 1-14

1-15 © 2011 Pearson Addison-Wesley. All rights reserved. IPO chart for Fahrenheit (F) to Celsius temperature (C) InputProcessOutput Enter FahrenheitCalculate Celsius using the formula Print the Celsius value and the corresponding input values 1-15

1-16 © 2011 Pearson Addison-Wesley. All rights reserved. Algorithm: Fahrenheit (F) to Celsius (C) Start Get the Fahrenheit Calculate C = 5/9*(F-32) Print the value of C End 1-16

1-17 © 2011 Pearson Addison-Wesley. All rights reserved. Input 1-17

1-18 © 2011 Pearson Addison-Wesley. All rights reserved. Process 1-18

1-19 © 2011 Pearson Addison-Wesley. All rights reserved. Output 1-19

1-20 © 2011 Pearson Addison-Wesley. All rights reserved. Complete flowchart 1-20

1-21 © 2011 Pearson Addison-Wesley. All rights reserved Style Pointers Write modular programs Use descriptive variable names Provide a welcome message for the user Use a prompt before an input Identify program output Document your programs

1-22 © 2011 Pearson Addison-Wesley. All rights reserved. Any Questions 22