Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Decision Tables. 2  Introduction  construction  Types of Decision Tables  Limited Entry  Extended Entry  Combining of Rules  General Rule  Q.

Similar presentations


Presentation on theme: "1 Decision Tables. 2  Introduction  construction  Types of Decision Tables  Limited Entry  Extended Entry  Combining of Rules  General Rule  Q."— Presentation transcript:

1 1 Decision Tables

2 2  Introduction  construction  Types of Decision Tables  Limited Entry  Extended Entry  Combining of Rules  General Rule  Q & A

3 3  Some programs require solution using multiple decisions to produce the correct output.  This can be a difficult task as this is not always readily apparent  Decision Tables is a problem-analysis tool used to solved complex decision logic  Decision tables offer a complete, concise and logical way of relating combinations of actions to combinations of conditions

4 4  all appropriate conditions must be satisfied before the conclusion is drawn and the specified action or actions taken  The basic concept of the decision table is therefore the IF…and IF…THEN… relationship.  Decision Table is constructed before flow chart or structure chart is drawn

5 5  The four basic elements of the decision table are known as:  The condition stub  The condition entries/rules  The action stub  The action entries Condition stub Condition entries Action stub Action entries Decision Tables Quadrants

6 6  The condition stub describe the conditions to be tested  Condition entries describes the possible combination of Boolean values (Yes/No or simply Y/N) for the conditions  The action stub contains possible actions based on the conditions  and action entries describe the actions to be taken which correspond to each Boolean value of each condition.

7 7  Steps  List all possible conditions  Determine how many possible Boolean values combinations/rules. Since each condition has 2 outcomes (T/F), therefore the number of rules is determined by 2 n where n is the number of conditions e.g. with 3 conditions, there must be 6 rules - boolean columns 3. List all possible actions  For each rule, select the appropriate action/s. Indicate with ‘X’ or tick.

8 8  Consider the following simple logical situation  If it is cold and wet, I will take my sweater and umbrella.  If it is cold, I will take my sweater.  If it is wet, I will take my umbrella.  If it is neither cold nor wet, I will take neither.

9 9  STEP 1 : List all possible conditions  Is it cold?  Is it wet?  STEP 2 : Determine how many possible Boolean values combinations/rules  Conditions - 2  Thus rules = 2 2, which is 4

10 10 State of weatherRule 1Rule 2Rule 3Rule 4 Yes No Yes No Condition entries Condition stub Is it cold? Is it wet?

11 11  STEP 3 : List all possible actions  Take sweater  Take umbrella  Take neither

12 12  STEP 4 : For each rule, select the appropriate action/s indicated by ‘X’ or tick. The situation is expressed in a decision table as follows: State of weatherRule 1Rule 2Rule 3Rule 4 Is it cold? Is it wet? Yes No Yes No Take sweater Take umbrella Take neither Action stub Action entries

13 13  2 Types:-  Limited Entry Table  Extended Entry Table

14 14  expresses each condition in the condition stub as a question which can be answered ‘Yes’ or ‘No’ (2 states) – indicated by Y/N  If condition is inapplicable for any particular rule, entry is indicated by a dash/blank  The number of condition rules required is determine by the formula 2 n

15 15  Determine the rate of discount allowed and whether or not there is free delivery according to the purchaser and/or type of purchase. If the goods are assumed to be televisions with either 23 or 29 inches screens, dealers being approved or non-approved and the sets themselves being either walnut or plastic finish, solve the problem using a decision table if: 1.Non-approved dealers are allowed 5% discount. 2.Approved dealers are allowed – a.free delivery on 29 inch sets b.25% discount on 29 inch walnut c.20% on other sets

16 16 Discount Rule 1 Rule 2 Rule 3 Rule 4 Rule 5 Rule 6 Rule 7 Rule 8 Approved dealer?YYYYNNNN Walnut finish?YYNNYYNN 29” screen?YNYNYNYN 5% discountXXXX 20% discountXXX 25% discountX Free deliveryXX

17 17  Also known as Mixed Entry Table.  Used when the condition entry contains not a straight forward ‘Yes’ or ‘No’ answer  For example, a condition might be ‘DIRECTION’ and the condition entries ‘North’, ‘South’, ‘East’ and ‘West’.

18 18  The number of condition rules required is determine by the multiplying the number of outcome of each conditions.  E.g. condition1 has 2 outcome (Y/N) condition2 has 3 outcome (100,200,300) condition3 has 2 outcome (Y/N) Therefore no. of rules required 2x3x2 = 12 rules

19 19  An order will be approved if a guarantee is available and credit is $100, or if there is no guarantee but credit is $200 in which case special clearance does not apply, or if credit is $100, there is no guarantee and special clearance is given, or if credit is $300, there is no guarantee and no special clearance. If there is no guarantee, credit is $100 and special clearance is not given, the order is not approved and is returned to the client.

20 20 Order approval 123456789101112 Guarantee?YYYYYYNNNNNN Credit?100200300100200300100200300100200300 Special clearance? YNYNYNYNYNYN PassXXXX ReturnX

21 21  If, for any combination of rules, the condition entries are identical except for one row and the action entries are also identical, the two rules can be combined, a dash being inserted in place of the conditions which are not the same.

22 22  It is possible to combine rules if they are having the same actions.  E.g.  If it is cold or wet, I will take my jacket Weather 1Rule 1Rule 2Rule 3Rule 4 Is it cold? Is it wet? Yes No Yes No Take jacket Take nothing XX X X

23 23  It will be noted that for rules 1 and 2 in which the status of the first condition is Yes, the status of the second is immaterial. The action to be taken is the same whether the answer is Yes or No. This is indicated by a dash.  The new table will be: Weather 2Rule 1Rule 2Rule 3 Is it cold? Is it wet? Yes - No Yes No Take jacket Take nothing XX X

24 24  The new table for the problem on “Discount” is: DiscountRule 1Rule 2Rule 3Rule 4 Approved dealer?YYYN Walnut finish?Y-NN 29” screen?YNYN 5% discountX 20% discountXX 25% discountX Free deliveryXX

25 25  A carpenter needs a program that computes the price of any desk a customer orders based on the following input fields; order number, desk length in inches and width in inches (3 digits each, no decimals), type of wood (assumed valid type is entered), and a number of drawers (2 digits). The price is computed as follows:  The charge for all desk minimum is $200  If the surface area is over 750 sq. in., add $50  If the wood is “mahogany” add $150; for “oak” add $125. No charge is added for “pine”  For every drawer in the desk, there is an additional $30 charge


Download ppt "1 Decision Tables. 2  Introduction  construction  Types of Decision Tables  Limited Entry  Extended Entry  Combining of Rules  General Rule  Q."

Similar presentations


Ads by Google