Chapter 5 Desk Checking/Dry Running.

Slides:



Advertisements
Similar presentations
Desk Checking. Desk checking is a manual (non computerised) technique for checking the logic of an algorithm. The person performing the desk check effectively.
Advertisements

Repetition Control Structures
Programming Types of Testing.
CS0004: Introduction to Programming Repetition – Do Loops.
TEL 104 / MKK Fundamental Programming: Lecture 3
Logic and Algorithm. Developing an algorithm To help the initial analysis, the problem should be divided into 3 separate components: 1.Input: a list of.
Program Design and Development
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
Advanced Decisions and Loops Chapter Some Simple Schoolroom Statistics.
Fundamentals of Python: From First Programs Through Data Structures
Adapted from slides by Marie desJardins
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
A First Book of ANSI C Fourth Edition
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
Developing an Algorithm
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Developing an Algorithm
CPS120 Introduction to Computer Programming The Programming Process.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Repetition Control Structures Simple Program Design Third Edition A Step-by-Step Approach 5.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop.
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
An Introduction to Programming with C++ Sixth Edition
Flowcharts. Symbol Terminal Symbol: indicates the starting or stopping pointin the logic. Input/Output Symbol: Represents an input or output process in.
Flowcharts Lecture 12.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
VCE IT Theory Slideshows by Mark Kelly study design By Mark Kelly, vceit.com, Begin.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CS 240 Computer Programming 1
Programming revision Revision tip: Focus on the things you find difficult first.
Review Materials I (T) Subject : T0016 – ALGORITHM AND PROGRAMMING
Control Structures II Chapter 3
Chapter 2: Input, Processing, and Output
Chapter 2 Assignment and Interactive Input
Chapter 5: Control Structure
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.
Topics Introduction to Repetition Structures
Lecture 07 More Repetition Richard Gesick.
Algorithm and Ambiguity
Lecture 4B More Repetition Richard Gesick
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Program Design Introduction to Computer Programming By:
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Pseudocode algorithms using sequence, selection and repetition
MSIS 655 Advanced Business Applications Programming
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Coding Concepts (Basics)
Chapter 5 Loops.
Algorithm and Ambiguity
Problem Solving.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Spreadsheets, Modelling & Databases
Chapter 2 Control Structures.
CHAPTER 4 Iterative Structure.
Flowcharts and Pseudo Code
Topics Introduction to Repetition Structures
Chapter 4: Repetition Structures: Looping
Chapter 2: Input, Processing, and Output
Desk Checking.
CHAPTER 6 Testing and Debugging.
Introduction to Pseudocode
Presentation transcript:

Chapter 5 Desk Checking/Dry Running

Desk Checking/Dry running Basically it is the manual simulation/process of walking through a program’s logic on paper before actually writing the program (coding). Used to test for the correctness of the solution algorithm Vital to check for errors during development of the solution algorithm (before coding) so that these errors are not implemented Done during planning/design stage In a large system, if there is logical error, it is very difficult to trace back the program as it involves 1000s lines of codes. Eliminate most errors but cannot prove algorithm is 100% correct Analyze codes = time consuming = costly

Desk Checking/Dry running It involves Use pen and paper Tabulate All variables (one column for each) Conditions – result is T for True or F for False Output walk through the logic of the algorithm with specific test data. and keep track of the values of all variables through out the process.

Desk Checking/Dry running May involves 6 steps for desk checking the solution: Choose 2 or 3 sets of simple input data (may include one invalid data to test the condition, if any) . Define/calculate the expected result for each test case. Make a table of relevant variable names within the algorithm e.g. Read number, total, while counter < 10 etc.

Desk Checking/Dry running Walk the first test data through the algorithm, keeping a step-by-step record of the content of each variable as the data passes through the logic. Repeat the walk-through process using the next test data until the algorithm has reached its logical end. Check that the expected result matches the actual result in the walk-through. For some cases you may omit steps 1 & 2 (if you do desk check after you do analysis using stepwise)

Example 1– Problem spec Analyze the problem to accept customer name, purchase amount, amount paid and payment type (Cash or Card). Calculate and display the change.

Example 1– solution algorithm Read customerName, purchaseAmt, amtPaid, paymentType Calculate change change = amtPaid - purchaseAmt Display change

Example 1– Desk Checking Step 1 - Choose 2 or 3 valid simple input data Variables Data1 Data2 CustomerName purchaseAmt amtPaid paymentType Aziz 100.00 Card Ahmad 55.00 Cash

Example 1– Desk Checking Step 2 - Define/calculate the expected result for each test case. Variables Data1 Data2 change 0.00 45.00

Example 1- Desk Checking Step 3 - Make a table of relevant variable names statement Customer Name purchaseAmt amtPaid Payment Type change Output Data 1 Read Display Data 2

Example 1- Desk Checking Step 4 & 5 - walk-through process + record the content of each variable statement Customer Name purchaseAmt amtPaid Payment Type change Output Data 1 Read Display Aziz 100.00 Card 0.00 Data 2 Ahmad 55.00 Cash 45.00

Example2 – Problem Spec A program is required to read from the screen the length and width of a rectangular house block and the length and width of the rectangular house that has been built on the block. The algorithm should then compute and display the mowing time required to cut the grass around the house, at a rate of 2 square metres per minute. Chp 3 – Simple Program Design

Example3 – Problem Spec Find the average of 4 integers which lie between 0 and 100 (exclusive) using iterative control structure

Example3 – solution algorithm 1. Set num_count = 0, total = 0 2. While num_count < 4 2.1 Read number 2.2 If number > 0 AND number <100 2.2.1 total = total + number 2.2.2 Add 1 to num_count 3. Calculate average avg_num = total / num_count 4. Display avg_num

Example 1– Desk Checking Step 1 - Choose input data Data 1 Data 2 number 20,30,40,60 1, 40, -5, 29, 100, 99

Example 1– Desk Checking Step 2 - Define/calculate the expected result for each test case. Variables Data 1 Data 2 avg_num 37.50 42.25

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output Data1 1. Set 2. while T 2.1. Read 20 2.2. IF 2.2.1. total 2.2.2 Add 1 30

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output 2.2.1. total 50 2.2.2 Add 2 2. while T 2.1. Read 40 2.2. IF 90 3

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output 2.1. Read 60 2.2. IF T 2.2.1. total 150 2.2.2 Add 4 2. while F 3. avg_num 37.50 4. Display

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output Data2 1. Set 2. while T 2.1. Read 1 2.2. IF 2.2.1. total 2.2.2 Add 40

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output 2.2.1. total 41 2.2.2 Add 2 2. while T 2.1. Read -5 2.2. IF F 29

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output 2.2.1. total 70 2.2.2 Add 3 2. while T 2.1. Read 100 2.2. IF F 99 189

Example 3- Desk Checking Step 3 – List out variables, conditions, output statement num_count total While OK? number IF OK? avg_num output 2.2.2 Add 4 2. while F 3. avg_num 42.25 4. Display

Class Exercise 1 Calculate the discounted price of an item purchased. Design the algorithm and do the desk check

Class Exercise 2 Calculate the discounted price of an item purchased. Customers receive a discount of 15% on an item if the purchase price of the item is over $100. Design the algorithm and do the desk check