# title=Problem Solving: Decision tables

 ← Structure charts Decision tables Finite state machines →

Decision tables are compact and precise ways of modelling complicated logic, such as that which you might use in a computer program. They do this by mapping the different states of a program to an action that a program should perform. Decision tables take on the following format:

 Conditions Condition alternatives Actions Action entries

The limited-entry decision table is the simplest to describe. The condition alternatives are simple Boolean values, and the action entries are check-marks, representing which of the actions in a given column are to be performed.

A technical support company writes a decision table to diagnose printer problems based upon symptoms described to them over the phone from their clients. They type the following data into the advice program:

1. Printer does print
2. Red light is flashing
3. Printer is recognised

The program then uses the decision table to find the correct actions to perform, namely that of Check / Replace ink.

 Rules Conditions Printer does not print Y Y Y Y N N N N A red light is flashing Y Y N N Y Y N N Printer is unrecognised Y N Y N Y N Y N Actions Check the power cable X Check the printer-computer cable X X Ensure printer software is installed X X X X Check/replace ink X X X X Check for paper jam X X
Example: Decision Tables

Let's take a look at a computer game example, for a football simulation the following rules are set up.

Rules
Conditions 90 minutes Y Y Y
Team A Winning Y
Team B Winning Y Y
Draw Y
Actions Game Over X X
Team A Wins X
Team B Wins X
Extra Time X
Keep Playing X X

What happens when:

1. 90 minutes up
2. the game is a draw

Answer: Keep Playing and give them some extra time

Exercise: Decision Tables
Create a decision table for the following program in an office email system
• Send email when Recipient address present, subject present, before 5:30pm
• If after 5:30pm then put in pending folder
• If Recipient address missing or subject message, give warning message

This question is open to interpretation, but you should have something resembling this:

Rules
Conditions Address Present Y Y Y
Subject Present Y Y Y
Before 5:30 Y Y Y
Actions Send Mail X
Error Message X X
Make pending X

Describe the use of Decision Tables