You are on page 1of 34

Software Development

Legacy International School


The program development life cycle
The program development life cycle is divided into five stages:
➢ Analysis – requirements specification
➢ Design – how the program should be developed
➢ Coding – set of programs
➢ Testing – run many times with different sets of test data
➢ Maintenance.

3
Computer systems
• A computer system is made up of software, data, hardware,
communications and people.
• The component parts of any computer system are:
➢ Inputs - the data used by the system that needs to be entered
while the system is active
➢ processes – the tasks that need to be performed using the
input data and any other previously stored data
➢ outputs – information that needs to be displayed or printed for
the users of the system
➢ storage – data that needs to be stored in files on an
appropriate medium for use in the future.

4
Example: an alarm app
• For example, the alarm app can be decomposed into:
❖ inputs – time to set the alarm, remove a previously set alarm
time, switch an alarm off, press snooze button
❖ processes – continuously check if the current time matches an
alarm time that has been set, storage and removal of alarm
times, management of snooze
❖ outputs – continuous sound/tune (at alarm time or after snooze
time expired)
❖ storage – time(s) for alarms set.

5
Methods used to design and construct a solution
to a problem

structure
flowcharts pseudocode.
diagrams

6
Structure diagrams

• Structure diagrams can be used to show top-down design in a diagrammatic


form.
• Structure diagrams are hierarchical, showing how a computer system solution
can be divided into sub-systems.

7
Alarm app

Set alarm Check time Sound alarm

Play sound
Turn alarm Check Reset/clear
Set time for two
on/off off/snooze alarm
minutes

Fig. Structure diagram for alarm app


8
Flowcharts

➢A flowchart shows diagrammatically the steps required to complete a task and


the order that they are to be performed.

➢These steps, together with the order, are called an algorithm.

➢Flowcharts are an effective way to communicate how the algorithm that makes
up a system or sub-system works.

9
Checking for the alarm time START

Get Time

Time =
Wait 30
Alarm
seconds
Time?

Sound Alarm

STOP
Fig. Flowchart for check time sub-system
10
Flowcharts symbols

11
Flowcharts symbols

Start/ Begin Terminator flowcharts


• Indicates the start or end of an
Stop/ End algorithm

• at the beginning and end of each


START flowchart.

STOP

12
Flowcharts symbols

Process Process flowcharts

• Process flowchart symbols are used to


show actions,
• for example, when values are assigned
to variables.
A  0
B  0

13
Flowcharts symbols

Process flowcharts

Sort list • If a process has been defined


elsewhere then the name of that
process is shown.

14
Flowcharts symbols
Input and output flowcharts
• The same flowchart symbol is used to show the input of data
and output of information.

OUTPUT
INPUT X “Error”

15
Flowcharts symbols

Decision
Decision flowcharts
• Decision flowchart symbols are
used to decide which action is to
be taken next; these can be used
for selection and repetition/
iteration.
yes
x > B? B  x
• There are always two outputs
no
from a decision flowchart
symbol.
16
Activity 1

Draw a flowchart for making a cup of coffee. Use the following


algorithm:
1. Fill kettle with water.
2. Turn on kettle.
3. Place coffee in cup.
4. Wait for water to boil.
5. Pour water into cup.
6. Add milk and sugar.
7. Stir.

17
Start
Activity 1
Fill kettle with 1. Fill kettle with water.
water 2. Turn on kettle.
3. Place coffee in cup.
4. Wait for water to boil.
Turn on kettle 5. Pour water into cup.
6. Add milk and sugar.
7. Stir.
Place coffee
in cup

wait for water Pour water Add milk and


Stir Stop
to boil into cup sugar

18
Start

Input three Example 1


values

Draw a flowchart for calculating the average


of three numbers.
Calculate the average

Display the
average

End
19
Start

Fill kettle with water

Turn on kettle
Example 2
Draw a flow chart for making a cup of
Is temperature of NO coffee.
water = 100 °C?

YES
Pour water into cup

Add milk and sugar

Stir

Stop 20
Mathematical operators
• The variable on the left of the  is assigned the value of the
expression on the right.

Operator Action
+ Add
- Subtract
* Multiply
/ Divide
^ Raise to the power
( ) Group
21
START

Example 3
Enter first
number
Draw a flow chart to calculate total by
Enter second adding first and second numbers.
number

Total  first number + Algorithm:


second number 1. Enter first number.
2. Enter second number.
Output total 3. Calculate total by adding first and
second number.
4. Output total
STOP

22
START
Example 4
Input num1
Draw a flow chart to calculate total by
Input num2
adding first and second numbers.

sum  num1 + num2

sum

STOP

23
START Example 5
Enter first number
Draw a flow chart to calculate total by
Enter second
multiplication of first and second
number numbers.

Total  first number * second


number

Output total

STOP
24
START

Output “First Example 6


Number?”

Input num1 • Draw a flow chart to display:


• Ask the user to input a number
Output “Second • Adding two numbers and
Number?”
• Display the result.
Input num2

sum  num1 + num2

Output “The result of adding


two numbers is”, sum

STOP 25
Example 7
START

Output “Enter • Draw a flow chart to display:


Number”
• Ask the user to input a number
Input num
• Multiply it by 5
• Display the result.
answer  num * 5

Output “The result is”,


answer

STOP

26
Start
Example 8
output "Enter a
number"

• Draw a flow chart to


input num
decide the given input is
even or odd.
remainder  num%2

No
Yes remainder
== 0?

output "The given output "The given


number is even" number is odd"

Stop 27
Example 9

Draw a flowchart for the system which performs:


Step 1: the user to input two numbers
Step 2: add two numbers
Step 3: decide whether the addition result is even or odd
Step 4: if even, multiply the addition result by 2
Step 5: if odd, multiply the addition result by 3
Step 6: display the final result

28
Start

output "Enter the first number"


Example 9
input num1

output "Enter the second number"

input num2

sum = num1 + num2

remainder = sum%2

Yes No
remainder == 0?

result = sum * 2 result = sum * 3

output "The final result


is", result

Stop 29
Example 10

Draw a flowchart for the system which performs:


Step 1: the user to input two numbers
Step 2: add two numbers
Step 3: decide whether the addition result is even or odd
Step 4: if even, go back to step 1 again
Step 5: if odd, display the result

30
Start

output "Enter the first number"


Example 10
input num1

output "Enter the second


number"

input num2

sum = num1 + num2

remainder = sum%2

Yes
remainder == 0?
No
output "The result is", sum

31
Stop
Example 11

Draw a flowchart for the system which performs:


Step 1: the user to input random number between 0 to 100
Step 2: repeat asking the user until the input number is 56
Step 3: display how many time the user guessed to get the correct
number

32
Start

count = 0

output "Enter the number


between 0 to 100"

input num Example 11

count = count + 1

No
num == 56?

Yes
output "You guess the correct
number within", count

Stop
33
Start

Example 12
num = 0
ans = 0

Draw a flow chart to find the


sum of all positive numbers ans = ans + num

between 1 and 100.


num = num + 1

No
num > 100

Yes

Output “The sum of positive


numbers between 0 and 100 is “,ans

Stop

34
Exercise
1. Draw a flow chart to find the product of all positive numbers
between 1 and 100.
2. Draw a flow chart to show the result of multiplying two input
numbers.
3. Draw a flow chart to find the sum of positive integers until the
result is less than 1000.
4. Draw a flow chart to
• Input the marks of three subjects
• Find the total mark
• Decide pass or fail
• Display the total mark and pass or fail

35

You might also like