Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 58

System Development Stages

Life cycle stages


• There are four stages in the program
development life cycle:
• Analysis
• Design
• Coding
• Testing
Name of the Stage A short description that what is it

Analysis Abstraction, decomposition of the


problem, Understanding the requirement of the
organization
Stages of Design and planning Design team develops code in the form of
flowcharts and pseudocode
development Planning of timeline is done
of programs Development Programmer program the system

Testing Testing runs along the development /coding process

Implementation System is implemented in the organisation ,


installation and use of system by users

Evaluation Everyone gives feedback on the systems, strengths


and improvements
Problem and requirements
• A basketball team wants some software
which will automatically send players
updates of when and where games are
held and results of matches
• A project may start with such an overall aim
• The analysis section will aim to determine exactly
what the problem is and what the requirements are
Problem and requirements
• A basketball team wants some software
which will automatically send players
updates of when and where games are
held and results of matches
• Example questions:
• What information needs to be stored and sent
out for the game information?
• How will the updates and results be sent?
• Which results are sent out?
• Do the results need further analysis?
• How often are updates sent out and who
are they sent to?
Requirements
• Once the problem has been
decomposed it is possible to produce
a list of requirements
• This is often called a requirements specification

• Requirements for the basketball software:


1. The software will store the game, place, date,
time and result
2. One email will be sent three days before
the game
3. The result will be sent as soon as the game
is over
4. All current players will be stored in the system;
only these players will be sent the information
Problem decomposition
• When we build a house we decompose
the problem into different parts such as
how many rooms are needed
• In problem decomposition, we break down
the problem into all the smaller parts that
need to be solved
• Problem decomposition is from the client point
of view – it shows each part of the problem but
not how it will actually
be solved
Abstraction
• Abstraction involves removing unnecessary
detail from a problem so that you can focus
on the essential components
• The London Underground map is a good example
of abstraction
Abstraction
• When you write a program to play a game
involving dice with a computer, how does
the computer ‘roll the dice’?
Rolling dice- Abstraction
• When a computer rolls a dice we can use abstraction to remove
unnecessary details
• It will depend on the problem being solved as to
what is and isn’t important
• A computer game may need to show a graphical representation of a dice – but they
may be able
to abstract away all the details about the surface
it rolls onto and the physics of the bounce
• Many programs just need a random number –
in which case they don’t need to worry about
how the dice appears, its weight or how the
spots are arranged – they can just find a random
number with one line of programming code
Design
• The design stage takes the requirements
that come out of the Analysis stage
• In the design stage, we are considering how the
program and software itself will be designed
• We are interested in both the overall structure
and individual algorithms that may be used
Decomposition
• A key part of the design stage
is decomposition
• The problem and requirements are broken down
into smaller parts that are solvable by a computer
• In the design stage, we are interested in how
we solve the problem. The problem is broken
down into component parts such as:
• Inputs, processes, outputs and storage
• Structure diagrams are a graphical way of
showing how a problem is broken down
Design Includes: Making of Structure
Diagram
Structure diagrams
• A structure diagram uses
boxes and branches
• Each part of the problem is broken
down again and again until each
part is easy enough to understand
and develop
• Compete a structure diagram for
the requirements
Basketball
software

Store current
player details
Structure diagrams
• One possible answer is shown below
• More levels would be required
for larger projects

Basketball
software

Store current
Store details Results
player details

Create emails Send emails


Example
Structure Diagram of a calculator ( Input, Process, Output)
Flowchart breaks down the system further by
explaining the flow of system
Name Operator
less than <
Greater than >
Less than or equal to <=
Operators Greater than or equal to >=
Equal ==
Not Equal <> , ≠
Modulus MOD
Dividend DIV
Operation Result

4 <= 3 ( less than or equal to) False

5 < > 4 ( not equal to) True

4 >= 4 ( greater than or equal to) True

3 < 4 ( less than) True

15 /2 ( Division) 7.5

10 * 2 ( multiplication) 20

Operators 2 ^ 4 ( power)

10 MOD 2 ( Modulus)
16

Use 10 DIV 2

7 MOD 10
( Dividend) 5

examples 100 DIV 10 10

15 DIV 10 1

15 MOD 10 5

( 40 MOD 10= =0 ) AND ( 35 MOD 10= = 0 ) False / AND will return a true if both the conditions around AND
are true
40 MOD 10 == 0 is true, but 35 MOD 10 == 0 is false

( 40 MOD 10 = 0 ) OR ( 35 MOD 10 = 0) True / OR will return a true if either of the condition around OR is
true or both are true
40 MOD 10 == 0 is true, but 35 MOD 10 == 0 is false

NOT ( 40 MOD 10 == 0 ) False , 40 MOD 10 == 0 is true but Not is applied outside this
condition that is why True is turned to False. Not Turns True to
False and False to True
Shapes of
the flowchart
Pseudocode To
design
algorithm
Data types and operations
Unit 9 Key programming concepts

Data types
• Variables will typically be one of the following types:
• Integer, Boolean, real, char or string
• For the variables given, the data types would be:
• numberOfStudents Integer
• circleArea Real
• found Boolean
• answer Char
• studentName String
• DOB Date
• The data type used will determine the amount of memory that needs to be allocated for the
variable
Data types and operations
Unit 9 Key programming concepts

Declaring variables
• Before using variables they should be declared
• Declaring a variable gets it ready for use in the program
• The data type is given to the variable – the programming language (compiler) can
check that it is being used correctly
• Examples of declaring and using variables
DECLARE sidesInShape : INTEGER
DECLARE name : STRING
sidesInShape ← 4
Name ← "Jody"
Data types and operations
Unit 9 Key programming concepts

Using variables and constants in a


program
• You have probably used variables in many different ways in programs
you have already written. All bold are variables
numberOfStudents ← numberOfStudents + 1
circleArea ← 3.142 * radius^2
WHILE NOT found…
answer ← 'Y'
OUTPUT studentName
Data types and operations
Unit 9 Key programming concepts

Constants
• As well as variables, you can define constants in a program
CONSTANT Pi ← 3.14157926535
CONSTANT VAT ← 0.2
CONSTANT MaxPlayers ← 6

• Constants are often shown in uppercase


• Words are separated with an underscore, e.g. MIN_AGE
• This is known as snake case
Data types and operations
Unit 9 Key programming concepts

Constants
• Why declare a constant instead of a variable?
• This prevents the value from being changed accidentally by a part of code
• It shows a programmer that the value should stay the same throughout the program

• Can a constant ever change its value?


• A constant cannot be changed when the program is running
• A constant can be changed by a programmer before the program is compiled or
translated
Data types and operations
Unit 9 Key programming concepts

Input and output statements_ How to take


input in the Pseudocode

• Most programs accept data from the user, process it


in some way, and output a result
OUTPUT "How many hours a night do you
sleep?"
INPUT hoursPerNight
hoursPerWeek ← hoursPerNight * 7
OUTPUT hoursPerWeek
Data types and operations
Unit 9 Key programming concepts

Arithmetic operators
• The operators +, -, * and / are used for addition, subtraction, multiplication and
division
• ^ is used for an exponent (power of)

• The operator DIV is used for integer division, also known as quotient
• MOD (modulus) is used to find the remainder when dividing one integer by another
• What is the result of the following operations?
• weeks ← 31 DIV 7
• daysLeft ← 31 MOD 7
Data types and operations
Unit 9 Key programming concepts

MOD and DIV


• weeks ← 31 DIV 7
• The variable weeks is assigned the value 4
• This is because 7 goes into 31 four times (remainder 3)

• daysLeft ← 31 MOD 7
• The variable daysLeft is assigned the value 3
• This is because the remainder after the division is 3
Data types and operations
Unit 9 Key programming concepts

Orders of precedence
• Remember BIDMAS
• Brackets
• Indices
• Division
• Multiplication
• Addition
• Subtraction
• Calculate: x ← (5 – 2) + (16 – 6 / 2)
y ← 7 * 3 + 10 / 2
Data types and operations
Unit 9 Key programming concepts

Concatenating strings
• Concatenating means joining together
• The + concatenate operator is used to join together strings
firstname ← "Rose"
surname ← "Chan"
fullname ← firstname + " " + surname
OUTPUT fullname
• What will be output? , Rose Chan
• What will be output by the program?
x ← "6" + "3"
OUTPUT x 63
Data types and operations
Unit 9 Key programming concepts

String handling functions


Function Example Result
LENGTH(str) word ← "Algorithm" 9
OUTPUT LENGTH(word)
OUTPUT(SUBSTRING( w
SUBSTRING(str, start, length) ord,3,6) “gorith"

LCASE(str) LCASE(word) algorithm


UCASE(str) UCASE(word) ALGORITHM

• What will be the values of a, b, c and d below? Assume indexing starts at 1


zooName ← "London Zoo"
a ← LEN(zooName)
b ← SUBSTRING(zooName,4,5) don Z
c ← LCASE(zooName) - london zoo
d ← UCASE(zooName)- LONDON ZOO
e ← zooName[2] o
Data types and operations
Unit 9 Key programming concepts

How to print a Name with Initial of first Name


and full last Name with a space, Assume
index starts at 1
firstName= “zayan”
lastName= “tauseef”
FirstLetter = UCASE ( firstName[1])
FirstLetterLastName= UCASE( lastName[1])
Output FirstLetter + “ “+ FirsLetterLastName+ Substring(lastName, 2,6)
Data types and operations
Unit 9 Key programming concepts

Comparison expressions, you


know what they are
• The condition average >= 80 is a
Boolean expression
• The outcome will always evaluate to TRUE or FALSE
• Comparison operators include
= equal to
<> not equal to
> greater than
< less than
Sequence and selection
Unit 9 Key programming concepts

Complex Boolean expressions


• Boolean expressions can include the Boolean operators AND, OR and
NOT
• For example:
IF (mark < 0) OR (mark > 100) THEN …
Operator Description

AND Returns TRUE if both conditions are TRUE

OR Returns TRUE if either of the conditions are TRUE

NOT A TRUE expression becomes FALSE and vice versa


Data types and operations
Unit 9 Key programming concepts

If statements
• If statements allow different branches to be executed
based on the result of a Boolean expression
IF average >= 60
THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Data types and operations
Unit 9 Key programming concepts

Nested if statements
• If statements may be nested:
IF member = "child"
THEN
IF day = "Saturday"
THEN
swimPrice ← 2.00
ELSE
swimPrice ← 2.50
ENDIF
ELSE
swimPrice ← 4.00
ENDIF

• What is the price for an adult on Saturday? , 4.00


• What is the price for a child on Sunday? 2.50
Data types and operations
Unit 9 Key programming concepts

CASE statements ( Selection Statement)


• Writing out lots of IF statements can be tedious
• CASE statements will branch depending on many different possible values for an identifier
INPUT Grade
CASE OF KeyPress
80 : OUTPUT(‘A’)
70 : OUTPUT(‘B’)
60 : OUTPUT(‘C’)
50 : OUTPUT(‘D’)
OTHERWISE OUTPUT “ Failed"
ENDCASE
Secondary storage
Unit 3 Computer architecture and storage

Total and Average with For loop


Write a pseudocode which takes temperatures input in Fahrenheit over a 10 hours (once per hour).Convert
the temperature in Celsius with the help of following formula:
TempC= ( TempF - 32)/1.8
Output the average temperature in Celcius in 10 hours

Total = 0
For Count 1 to 10
Output " Enter temp in Farenheit"
Input TempF
TempC= ( TempF- 32)/1.8
Total = Total + TempC
Next Count
Output Total / 10
Secondary storage
Unit 3 Computer architecture and storage

For loop to run according to user input


In the previous slide, the for loop is taking input of temperature of 10 hours. If you want user to decide to
how many inputs of temperature must be taken, the code will change as below.

Total = 0
Output "input no of hours"
Input hours
For Count 1 to hours
Output " Enter temp in Farenheit"
Input TempF
TempC= ( TempF- 32)/1.8
Total = Total + TempC
Next Count
Output Total / hours
Secondary storage
Unit 3 Computer architecture and storage

For Count 3 to 15 Step 3


Output Count

Next Count

Predict the Output of the above program

3 6 9 12 15
Construct pseudocode using For loop
• Write an algorithm in the form of pseudocode which takes temperatures input in Fahrenheit over a 100-day
period (once per day). Convert the temperature in Celsius with the help of following formula:

Temp (in Celsius)=(Temp (in Fahrenheit) - 32)/1.8

and output temperature in Celsius for each day, also print:

• count of number of days when the temperature was below 20C and the number of days when the
temperature was 20C and above.

• average temperature of 100 days.


Pseudocode
Count = 0
Total =0
For i 1 to 100
Output ‘ Enter temperature in Farenheit’
Input tempF
tempC=(tempF-32)/ 1.8
Total = Total + tempC
output ‘ temperature in Celcius’, tempC
if tempC < 20 then
Count = Count +1
End if
Next i
Avg= Total/ 100
Print ‘ Average temperature is’, Avg
Print ‘ days with temp below 20 are’, Count
Print ‘ days with temp above and equal to 20 are’ ,100- Count
Pseudocode problem
A car’s speed is measured between points A and B, which are 200 km
apart.

The final speed of the car is calculated using the formula:

Write an algorithm, using pseudocode, which inputs the time of each of


50 cars, calculates the speed of each car using the formula, and then
outputs speed of each of the 50 cars. Your pseudocode should also print
average speed of the 50 cars
Pseudocode
Total = 0
For count 1 to 50
output ‘ Enter the time to cover the distance between A to B’
input time
speed= 200/ time
output ‘speed of the car’ speed
Total = Total + speed
Next count
Avg = Total / 50
Output ‘Average speed of the cars’, Avg
A Teacher would like to create a simple program to take the input of marks
of 30 students and print appropriate message for each student grade and
print the average Mark of the class. Grade boundaries are given in the table
below
Create pseudocode/python program
• to take input of Marks of each of 30 students.
Create a • Print appropriate grade of each student
• Print the average Mark of the class
pseudocode/
python program Mark Grade
80 and above Distinction
60 and above Merit
40 and above Pass
Below 40 Fail
Algorithms and pseudocode
Unit 8 Algorithm design and problem solving

WHILE … ENDWHILE
For loop Alternative while loop
Total = 0
Total  0 Count = 1
FOR Count  1 TO 7 WHILE Count < = 7 DO
INPUT Temp Input Temp
Total  Total +
Total = Total +Temp
Temp
NEXT Count Count = Count +1
ENDWHILE
Algorithms and pseudocode
Unit 8 Algorithm design and problem solving

If statement within WHILE … ENDWHILE for counting

Count = 1
Count = 1 CountMore=0
WHILE Count < = 10 DO WHILE Count < = 10 DO
output “ Enter the output “ Enter the
score “ score “
Input Score Input Score
Count = Count +1 Count = Count +1
ENDWHILE if Score > 80
CountMore= CountMore+1
Endif
ENDWHILE
Print CountMore
Algorithms and pseudocode
Unit 8 Algorithm design and problem solving

While loop controlled by input


Algorithms and pseudocode
Unit 8 Algorithm design and problem solving

REPEAT … UNTIL
• Use this when you want to keep on executing a loop
UNTIL a certain condition is TRUE
• The condition is tested at the end of the loop so it is also
known as a post-condition loop
• Rewrite this algorithm using a REPEAT UNTIL loop
instead of a WHILE loop
Output “ Enter Password”
INPUT Password
WHILE Password <> "rE5Bh9dP" DO
Output “ Enter Password”
INPUT password
ENDWHILE
OUTPUT "Correct password"
Algorithms and pseudocode
Unit 8 Algorithm design and problem solving

Using REPEAT … UNTIL


• The condition is not tested until the end of the loop
• It is always executed at least once

Repeat
Output “ Enter Password”
INPUT password
UNTIL Password = "rE5Bh9dP"
OUTPUT "Correct password"
Three types of Iterations/ Loops/ Repetitions

For loop ( Fixed Repeat Until ( Condition Controlled) While loop ( condition
iterations) controlled)
Executes fixed number of time Checks Condition at the end Check condition at the beginning
Don’t have to increment the Executes instructions inside this loop at least once Doesn’t Execute instructions inside this loop
counter Runs until condition is False at all if condition is not met.
Runs until Condition is True

Total = 0 Total = 0 Total = 0


For Count 1 to 50 Count = 1 Count = 1
input Num Repeat While Count <= 50 do
Total = Total + Num input Num input Num
Next Count Total = Total +Num Total = Total +Num
Count = Count + 1 Count = Count + 1
Until Count = 50 End While
If then else End IF CASE of otherwise End CASE
Two Types of input GradeCS input GradeCS

Selection if GradeCS == “A” then Case GradeCS of


output “Excellent” “A” : output “Excellent”
statements Else if GradeCS== “B” then “B”: output “ Good”
output “ Good” “C”: output “ Fair”
else if GradeCS == “C” then Otherwise

NOTE output “ Fair” output “ You have failed the exam”

•CASE Selection statement is Else


used to avoid use of multiple output “ You have failed the exam End CASE
ifs. Endif
•CASE is used only for “ == “ Endif
Comparison but not for
Endif
greater than or less than
Development / Coding
• The next stage in the lifecycle is producing
the software itself. Based on the design completed.
After making flowcharts, pseudocode, coding process
starts
• This is often known as the development stage
Coding: Iterative testing and Maintenance
• Programs are tested as they are developed
• Each time the program is updated to add a new
feature or fix a problem is known as an iteration
• The testing of each iteration is known as
iterative testing
Testing
• The final stage of the product lifecycle is
the testing stage
• Before the program is written, a set of tests will
be designed along with expected results
• Once the program is complete, the tests will be
carried out with test data to check that the
program output matches the expected results
• If any tests fail, the errors are fixed before
being re-tested
• What could the test data be for a program that
reverses an integer that is between 1 and 5
digits long?

You might also like