2. Introduction
• We mentioned it already, that if we thing of an
analyst as being analogous to an
architect, and a developer as being analogous
to a builder, then the most important thing we
can do as analysts is to explain our designs to
the developers in a simple and clear way.
• How do architects do this?
3.
4. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and print it out.
25. START
Read in A
Does A/2
Print “It’s Odd” Yes
give a
remainder?
26. START
Read in A
Does A/2 No
Print “It’s Odd” Yes Print “It’s Even”
give a
remainder?
27. START
Read in A
Does A/2 No
Print “It’s Odd” Yes Print “It’s Even”
give a
remainder?
END
28. Flowcharts
• So let’s say we want to express the
following algorithm to print out the bigger
of two numbers:
– Read in two numbers, call them A and B. Is A is bigger
than B, print out A, otherwise print out B.
33. START
Read in A and B
Yes No
Print A A>B? Print B
34. START
Read in A and B
Yes No
Print A A>B? Print B
END
35. Flowcharts
• So let’s say we want to express the
following algorithm to print out the bigger
of three numbers:
– Read in three numbers, call them A, B and C.
• If A is bigger than B, then if A is bigger than C, print out
A, otherwise print out C.
• If B is bigger than A, then if B is bigger than C, print out
B, otherwise print out C.
54. Flowcharts A=A+1
• If I say A = A + 1, that means “A gets the
value of whatever is in itself, plus 1”
• If A is 14
• It becomes 15
14 +1
A (old)
15
A (new)
62. Flowcharts
• So let’s say we want to express the
following algorithm:
– Add up the numbers 1 to 5
63. Flowcharts T=5
• But first a few points;
• If I say T = 5, that means “T gets the value
5”
64. Flowcharts T=5
• But first a few points;
• If I say T = 5, that means “T gets the value
5”
T
65. Flowcharts T=5
• But first a few points;
• If I say T = 5, that means “T gets the value
5”
5
T
66. Flowcharts T=X
• If I say T = X, that means “T gets the value
of whatever is in the variable X”
67. Flowcharts T=X
• If I say T = X, that means “T gets the value
of whatever is in the variable X”
• So if X is 14, then T will get the value 14.
68. Flowcharts T=X
• If I say T = X, that means “T gets the value
of whatever is in the variable X”
• So if X is 14, then T will get the value 14.
14
X
14
T
69. Flowcharts T=X+1
• If I say T = X+1, that means “T gets the
value of whatever is in the variable X plus
one”
70. Flowcharts T=X+1
• If I say T = X+1, that means “T gets the
value of whatever is in the variable X plus
one”
• So if X is 14, T becomes 15, and X stays as
14.
71. Flowcharts T=X+1
• If I say T = X+1, that means “T gets the
value of whatever is in the variable X plus
one”
• So if X is 14, T becomes 15, and X stays as
14.
+1 14
X
15
T
72. Flowcharts T=T+X
• If I say T = T + X, that means “T gets the
value of whatever is in itself plus whatever
is in the variable X”
73. Flowcharts T=T+X
• If I say T = T + X, that means “T gets the
value of whatever is in itself plus whatever
is in the variable X”
• If T is 14 and X is 9
• T becomes 23
• X stays at 9
74. Flowcharts T=T+X
• If I say T = T + X, that means “T gets the
value of whatever is in itself plus whatever
is in the variable X”
• If T is 14 and X is 9
• T becomes 23
14 9
• X stays at 9 T(old) X
23
T(new)
75. Flowcharts
• So let’s say we want to express the
following algorithm:
– Add up the numbers 1 to 5
82. START
Total = 0
A=1
A=A+1
No
Is A==6? Total = Total + A;
Yes
END
83. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and check if it’s a prime number.
84. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and check if it’s a prime number.
– What’s a prime number?
85. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and check if it’s a prime number.
– What’s a prime number?
– A number that’s only divisible by itself and 1, e.g. 7.
86. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and check if it’s a prime number.
– What’s a prime number?
– A number that’s only divisible by itself and 1, e.g. 7.
– Or to put it another way, every number other than itself and 1
gives a remainder, e.g. For 7, if 6, 5, 4, 3, and 2 give a remainder
then 7 is prime.
87. Flowcharts
• So let’s say we want to express the
following algorithm:
– Read in a number and check if it’s a prime number.
– What’s a prime number?
– A number that’s only divisible by itself and 1, e.g. 7.
– Or to put it another way, every number other than itself and 1
gives a remainder, e.g. For 7, if 6, 5, 4, 3, and 2 give a remainder
then 7 is prime.
– So all we need to do is divide 7 by all numbers less than it but
greater than one, and if any of them have no remainder, we
know it’s not prime.
88. Flowcharts
• So,
• If the number is 7, as long as 6, 5, 4, 3, and
2 give a remainder, 7 is prime.
• If the number is 9, we know that
8, 7, 6, 5, and 4, all give remainders, but 3
does not give a remainder, it goes evenly
into 9 so we can say 9 is not prime
89. Flowcharts
• So remember,
– if the number is 7, as long as 6, 5, 4, 3, and 2
give a remainder, 7 is prime.
• So, in general,
– if the number is A, as long as A-1, A-2, A-3, A-
4, ... 2 give a remainder, A is prime.