Home » qbasic » 05 SIPOS Design

05 SIPOS Design

SIPOS is a simple design process that allows you design a simple program and produce the code automatically, while also producing the final paper-based documentation.  This methodology works well for BTEC Software development courses. If you do not skip a step and throughly test each stage, you will produce a working solution much faster than just ‘messing about and dabbling.’ with making the code first that newbies normally want to do….

(Input/Output Data and calculations/processes)

Learning Objectives

At the end of this tutorial you will know about:

  • Understand how to design software and use a design tool
  • Be able to design and create a program
  • Technical documentation: requirements specification; other as appropriate  structure charts, data dictionary

1) Work out the problem’s calculation backwards

2) Put calculations into the Process Column. Make sure you arrange them this way:

Answer = Calculation

3) Check you have used brackets (BODMAS) if required, because multiply and divide is always done before add and subtract . e.g. A = 4 + 6 / 2 A = 7. A= ( 4 + 6)/2 A= 5

4) Work through the right hand side of the calculations and decide whether the variables are input, stored or a calculated output from a previous calculation.

5) Work through the input, output and stored variables and decide if they are:

INTEGER (int)- The largest integer value is 215= ±32768
LONG (lng) – The largest integer value is 231= ±2147483648
SINGLE (sng) – Single-precision floating-point variables can represent a number up to seven digits in length. The decimal point can be anywhere within those digits.
DOUBLE (dbl) – Double-precision floating-point variables can represent a number up to 15 digits in length. The decimal point can be anywhere within those digits.

Problem work out the cost of painting a ceiling

A) Work backwards from the final answer

PaintCost = Price per litre X Litres needed

Price is given, but litres needed require calculation.

Litres Needed = Tins Needed X SizeOfTin

Size of tin is given, but tins needed require calculation.

TinsNeeded = CeilingArea / CoverageOfTin

Coverage of a tin is given, but area needed require calculation.

CeilingArea = Width Of Room X Length Of Room

Both width and length will be input for each room

Place the calculation in reverse order into the SIPO table

Stored

Input


Processes

Outputs

 


CeilingArea = WidthOfRoom * LengthOfRoom


TinsNeeded = CeilingArea / CoverageOfTin


LitresNeeded = TinsNeeded X  SizeOfTin


PaintCost = TinPricePerLitre * LitresNeeded

 

B) Work out for each calculation, what is output and what needs to be input or previously stored.

Work right to left

CeilingArea = WidthOfRoom * LengthOfRoom
WidthOfRoom is INPUT
LengthOfRoom is INPUT
CeilingArea is Output
TinsNeeded = CeilingArea / CoverageOfTin
CeilingArea is already available as output
CoverageOfTin is to be stored in the program
TinsNeeded is output
LitresNeeded = TinsNeeded X SizeOfTin
TinsNeeded is already available as output
SizeOfTin is to be stored in program
LitresNeeded is output
PaintCost = TinPricePerLitre * LitresNeeded
TinPricePerLitre is to be stored in the program
LitresNeeded is already available as output
PaintCost is output

Stored

Input

Processes

Outputs

CoverageOfTin

TinPricePerLitre

SizeOfTin

 

WidthOfRoom

LengthOfRoom

 

CeilingArea =
WidthOfRoom * LengthOfRoom

TinsNeeded =
CeilingArea / CoverageOfTin

LitresNeeded =
TinsNeeded X  SizeOfTin

PaintCost =
TinPricePerLitre* LitresNeeded

 

CeilingArea

TinsNeeded

LitresNeeded

PaintCost

C) Design Stage Work out varable type

Stored

Input

Processes

Outputs

CoverageOfTin

TinPricePerLitre

SizeOfTin

 

WidthOfRoom

LengthOfRoom

 

CeilingArea =
WidthOfRoom * LengthOfRoom

TinsNeeded =
CeilingArea / CoverageOfTin

LitresNeeded =
TinsNeeded X  SizeOfTin

PaintCost =
TinPricePerLitre* LitresNeeded

 

CeilingArea

TinsNeeded

LitresNeeded

PaintCost

D) Use the table to produce the Structure chart

image002

E) Produce a data dictionary

The can also be used to help design the Input and output screens. Note there are no whole numers and none of them exceed 7 digits. Single precision are therefore acceptable as variables

Item Variable Name

Type

Format
Picture/Length

sngCoverageOfTin

sngPricePerLitre

sngSizeOfTin

sngWidthOfRoom


sngLengthOfRoom

dblCeilingArea

sngTinsNeeded

sngLitresNeeded

sngPaintCost

sngCoverageOfTin

sngPricePerLitre

sngSizeOfTin

sngWidthOfRoom


sngLengthOfRoom

dblCeilingArea

sngTinsNeeded

sngLitresNeeded

sngPaintCost

 single

single

single

single

single

single

single

single

single

 99.99

99.99

99.9

99.99

99.99

99999.99

99.99

9999.99

9999.99

F) Create the Screen Design

part_53

G: Creating the program

You can use the SIPO table to produce the program

The input, output and stored variables can be used pasted at the beginning and turned into DIM statements

DIM sngCoverageOfTin AS SINGLE
DIM dblTinPricePerLitre AS SINGLE
DIM sngSizeOfTin AS SINGLE
REM Input variables
DIM sngWidthOfRoom AS SINGLE
DIM sngLengthOfRoom AS SINGLE
REM Calculatated variables
DIM dblCeilingArea AS SINGLE
DIM sngTinsNeeded AS SINGLE
DIM sngLitresNeeded AS SINGLE
DIM sngPaintCost AS SINGLE

The add the stored values and turn them into LETS

REM Stored values
LET sngCoverageOfTin= 40
LET sngTinPricePerLitre = 5.2
LET sngSizeOfTin = 2.5

Add the INPUTS

INPUT sngWidthOfRoom
INPUT sngLengthOfRoom

Add the calculations

LET dblCeilingArea = sngWidthOfRoom * sngLengthOfRoom
LET sngTinsNeeded = dblCeilingArea / sngCoverageOfTin
LET sngLitresNeeded = sngTinsNeeded * sngSizeOfTin
LET sngPaintCost = sngPricePerLitre * sngLitresNeeded

then print the answers out using the outputsdblCeilingArea

REM Display the answers
PRINT sngTinsNeeded
PRINTsngLitresNeeded
PRINT sngPaintCost
END

Note a better way to store values that don’t change in program is to use CONST to declares symbolic constants. The following comes from the QBASIC help file.

CONST constantname = expression [

constantname: The name of the constant. This name can consist of up to 40 characters and must begin with a letter. Valid characters are A-Z, 0-9, and period (.). expression

An expression that is assigned to the constant. The expression can consist of literals (such as 1.0), other constants, any arithmetic or logical operators except exponentiation (^), or a single literal string. Place the CONST after your DIMs. It is good practice to put the DIMs/CONSTs in alphabetical order.

Example:

CONST PI = 3.141593
CONST intCoverageOfTin= 40
CONST dblTinPricePerLitre = 5.2
CONST sngSizeOfTin = 2.5

Support