Top-down Program Design Selim Aksoy Bilkent University Department of Computer Engineering

Slides:



Advertisements
Similar presentations
A number of MATLAB statements that allow us to control the order in which statements are executed in a program. There are two broad categories of control.
Advertisements

Lecture 2: Developing Procedural Thinking (How to think like a programmer) BJ Furman 06FEB2012.
User-defined Functions Selim Aksoy Bilkent University Department of Computer Engineering
Chapter 3 Program Design And Branching Structures.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
INTRODUCTION TO PROGRAMMING
Algorithm –History Muhammad ibn Musa Al-Khwarizmi www -groups.dcs.st-andrews.ac.uk/~history/Mathematicians/Al- Khwarizmi.html Book on arithmetic:
COEN 352 Data structures and Algorithms R. Dssouli.
17 March, 2000 CS1001 Lecture 2 Programming and problem solving Software engineering practices.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Chapter 3 Program Design and Branching Structures Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering.
Branches and Loops Selim Aksoy Bilkent University Department of Computer Engineering
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Top-down Program Design, Relational and Logical Operators
User-defined Functions Selim Aksoy Bilkent University Department of Computer Engineering
Program Design, Relational and Logical Operators Selim Aksoy Bilkent University Department of Computer Engineering
Chapter 1 Program Design
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Relational and Logical Operators Selim Aksoy Bilkent University Department of Computer Engineering
Chapter 3 Planning Your Solution
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Software Engineering 1 (Chap. 1) Object-Centered Design.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
1 Programming and Problem Solving — Software Engineering (Read Chap. 2)
Introduction to Matlab Creating Matlab Scripts Birth Year Program Get the user’s age as input Display the user’s birth year Use input() to get the age.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
Simple Program Design Third Edition A Step-by-Step Approach
Programming.
Computer Programming Basics Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University, Korea.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
An Introduction to Programming and Algorithms. Course Objectives A basic understanding of engineering problem solving process. A basic understanding of.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Computer Science 101 Introduction to Programming.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
October 3, 2005 Lecture 8 - By Paul Lin 1 CPET 190 Lecture 8 Problem Solving with MATLAB
1 Chapter-01 Introduction to Software Engineering.
I Power Higher Computing Software Development The Software Development Process.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Design & Analysis of Algorithms Lecture 1 Introduction.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Cs413_design04.ppt Design and Software Development Design : to create a functional interface that has high usability Development : an organized approach.
Branches and Program Design
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
Software Engineering Object-Centered Design. Problem Solving Does anyone scuba dive? Let’s solve this scuba-diving problem: Write a program that, given.
MATLAB 及其工程应用 MATLAB and It’s Engineering Application 主讲教师: 胡章芳
Software Engineering CS103 February 13, How Do You Solve Big Problems? Thousands of programmers Thousands of programmers Months or years of coding.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
1 Chapter-01 Introduction to Software Engineering.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
CSCI-235 Micro-Computer Applications
ALGORITHM Basic CONCEPTS of Basic Concepts of Algorithm
Introduction to Algorithms
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Programming We have seen various examples of programming languages
Understanding Problems and how to Solve them by using Computers
Data Structures and Algorithms CSE 465
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Life is Full of Alternatives
Programming Concepts and Database
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

Top-down Program Design Selim Aksoy Bilkent University Department of Computer Engineering

Summer 2004CS 1112 Creating MATLAB Scripts Choose File>New>M-file from the menu Use the editor to write your program Document your program using comments that include Short note about what your program does Short note about how it works Author information Date information Version information

Summer 2004CS 1113 Creating MATLAB Scripts % Script file: temp_conversion.m % % Purpose: % To convert an input temperature from degrees Fahrenheit to % an output temperature in kelvins. % % Record of revisions: % Date Programmer Description of change % ==== ========== ===================== % 12/01/97 S. J. Chapman Original code % % Define variables: % temp_f -- Temperature in degrees Fahrenheit % temp_k -- Temperature in kelvins % Prompt the user for the input temperature. temp_f = input('Enter the temperature in degrees Fahrenheit: '); % Convert to kelvins. temp_k = (5/9) * (temp_f - 32) ; % Write out the result. fprintf('%6.2f degrees Fahrenheit = %6.2f kelvins.\n',... temp_f,temp_k);

Summer 2004CS 1114 Top-down Program Design Start State the problem Define inputs and outputs Design the algorithm Convert algorithm into MATLAB statements Test the resulting program End Decomposition Stepwise refinement

Summer 2004CS 1115 Algorithm Systematic procedure that produces -in a finite number of steps- the answer to a question or the solution of a problem. The name derives from the Latin translation, Algoritmi de numero Indorum, of the 9th- century Muslim mathematician al-Khwarizmi's arithmetic treatise “Al-Khwarizmi Concerning the Hindu Art of Reckoning.” (Britannica) An algorithm is a sequence of finite number of steps arranged in a specific logical order which, when executed, will produce a correct solution for a specific problem.

Summer 2004CS 1116 Pseudocode A hybrid mixture of MATLAB and English for defining algorithms Independent of any programming language so it can be easily converted to any programming language Example pseudocode: Prompt user to enter temperature in degrees Fahrenheit Read temperature in degrees Fahrenheit (temp_f) temp_k (in Kelvins)  (5/9) * (temp_f – 32) Write temperature in degree Kelvins

Summer 2004CS 1117 Testing Test individual subtasks: unit testing Add tested components one by one and test them together: build Alpha release Beta release Test for all legal input data sets: standard data sets, ground truth

Summer 2004CS 1118 Top-down Program Design Problem: write a program that takes the radius and height (in meters) of a cylinder tank and the amount of water (in m 3 ) from the user and output the amount of extra space (in m 3 ) in the tank. Input: radius and height amount of water Output: extra space

Summer 2004CS 1119 Top-down Program Design Design: 1. Get radius of the tank base from the user 2. Get the height of the tank from the user 3. Get the amount of water 4. Calculate the amount of extra space 5. Write the result Step 4 is not clear enough, refine it: Calculate the capacity of the tank (pi * radius^2 * h) extra space  capacity - water

Summer 2004CS Top-down Program Design Code: r = input('Enter the radius of the tank base:'); h = input('Enter the height of the tank:'); water = input('Enter the amount of water:'); capacity = pi * r^2 * h; space = capacity - water; fprintf('There is %f m3 extra space in the tank', space);

Summer 2004CS Top-down Program Design Testing: Enter the radius of the tank base:2 Enter the height of the tank:5 Enter the amount of water:10 There is m3 extra space in the tank Continue testing: Enter the radius of the tank base:2 Enter the height of the tank:5 Enter the amount of water:100 There is m3 extra space in the tank

Summer 2004CS Top-down Program Design Design: refine step 4 again Calculate the capacity of the tank (pi * radius^2 * h) extra space  ((capacity – water) + abs(capacity – water))/2