CHAPTER 1:
SOFTWARE DEVELOPMENT
METHOD
Faculty of Electrical and Electronic Engineering
University Tun Hussein Onn Malaysia
NAS SEM 1 2020/2021 1
NAS SEM 1 2020/2021 2
Which one of this is a computer?
Toilet
Car bowl
Grocery
store
D0g
NAS SEM 1 2020/2021 3
Why do you need to learn programming?
https://www.youtube.com/watch?v=Dv7gLpW91DM
NAS SEM 1 2020/2021 4
WHY PROGRAMMING ?
It is important to develop problem solving skills.
Programming is all about solving problems
Require creativity and careful thought
Teaches you how to understand, analyze and solve
the problems
Enhances your analytical reasoning abilities and help
you cope with daily real life problems as well.
Learning to program is important because it develops
analytical and problem solving abilities.
NAS SEM 1 2020/2021 5
NAS SEM 1 2020/2021 6
NAS SEM 1 2020/2021 7
TERMINOLOGY
Program is a set of instruction for a computer to follow.
NAS SEM 1 2020/2021 8
TERMINOLOGY
Software is a collection of computer programs or instructions
or data used/stored by a computer.
NAS SEM 1 2020/2021 9
TERMINOLOGY
Hardware is actual
machines that make up a
computer installation
NAS SEM 1 2020/2021 10
https://www.codeit-project.eu/
NAS SEM 1 2020/2021 11
HISTORY OF C++
“C++ was written by Bjarne Stroustrup at
Bell Labs during 1983-1985. C++ is an extension
of C. Prior to 1983, Bjarne Stroustrup added
features to C and formed what he called ‘C with
Classes’.
He had combined the Simula's use of classes and
object-oriented features with the power and
efficiency of C. The term C++ was first used in
1983.“C++ was designed for the UNIX system
environment, it represents an enhancement of the
C programming language and enables
programmers to improve the quality of code
produced, thus making reusable code easier to
write.”
NAS SEM 1 2020/2021 12
SIMPLE VIEW OF RUNNING A PROGRAM
#incluide <iomanip>
using namespace std;
main()
{
int z, x, y, j;
char name[10];
cout<<“Hello…”
<<endl<<endl;
COMPILING AND RUNNING A C++ PROGRAM
C++ Program
Compiler A program that
.cpp file translates a high-level language
Compiler program (human readable program),
such as a C++ program into a
machine-language program that the
.i file computer can directly understand
Object Code for and execute.
C++ program
.asm file Linker A program that
Linker combines object code for your C++
program with the object code for
routines (such as input and output
routines).
.obj file Executable file
.exe file
NAS SEM 1 2020/2021 14
COMPILING AND RUNNING A C++ PROGRAM
(CONT’) – TYPES OF ERROR
Compiler Error
C++ Program Example: Divide the value stored in a variable called
sum by 3, the correct expression is sum/3.
The expression; sum\3 produces compiler error.
Compiler
Execution Error
Object Code for Cause the termination of program. If the program not
C++ program terminated, it will produced incorrect results.
Example: The program statements may attempt to
perform a division by zero.
Linker
Logic Error The program appears to execute
properly. However it produces incorrect results (because
Executable file of incorrect steps in the solution). Thus, recheck the
results carefully to be sure that they areNAS correct.
SEM 1 2020/2021 15
SOFTWARE DEVELOPMENT
MODEL
NAS SEM 1 2020/2021 16
Source: Andy M Tyrell, Stephen L. Smith and Jonathan A. Dell. (1999). The Essence of C for Electronic Engineers. Prentice Hall. Europe
Requirements
Specification • Understand and define the problem.
Data Analysis
• Specify data to input and output.
• Identify relevant mathematical formulae.
Design • Break problem into several smaller subproblems.
• Design algorithms to solve subproblems.
• use Pseudo code or flow chart
• Write the C++ program from algorithms developed in the design
Implementation stage.
• Three (3) types of programming errors: Logic, Syntax &
Runtime error
Testing & • Ensure that the program performs the required function
Verification properly.
• Run several times using different sets of data.
• This will require ‘debugging’ the program. NAS SEM 1 2020/2021 17
User’s
manual
Sample test
run
Well-commented
program listing
Algorithm
development &
changes
Program
description
DOCUMENTATION &
Maintenance
Is concerned with ongoing correction of problems, revision to
meet changing needs and addition of new features.
The better the documentation is, the efficiently this phase
can be performed.
NAS SEM 1 2020/2021 18
ALGORITHM DESIGN
Pseudocode & Flowchart
NAS SEM 1 2020/2021 19
WHAT IS ALGORITHM ?
Algorithm is a sequence of a finite number
of steps arranged in specific logical order
that, when executed, produces the solution
for a problem.
There two(2) techniques to represent
algorithm
pseudocode
flowchart
NAS SEM 1 2020/2021 20
• Describe the problem
solution in a simple
and narrative
PSEUDO-CODE notation.
• -Using short English
phrases
NAS SEM 1 2020/2021 21
HOW TO WRITE PSEUDOCODE
Make a list of the main tasks that must be
accomplished on a piece of scratch paper.
Focus on each of those tasks, try to break each
main task down into very small tasks that can
each be explained with a short phrase.
There may eventually be a one-to-one
correlation between the lines of pseudocode and
the lines of code that you write after finished
pseudocoding.
NAS SEM 1 2020/2021 22
CASE STUDY 1: DISPLAY “HI!”
Begin/ Start
1. Display Hi! on computer screen.
End / Stop
NAS SEM 1 2020/2021 23
CASE STUDY 2: DETERMINE VOTING
STATUS
Begin
Print “Enter your age”
Read age
if age is greater than or equal to 18
Print “ You can vote”
Else
Print “ You can’t vote !”
End
NAS SEM 1 2020/2021 24
• Graphical technique for
designing and representing
algorithm FLOWCHART
• Alternative to pseudocode
NAS SEM 1 2020/2021 25
FLOWCHART: SYMBOL & DESCRIPTION
indicates Begin or End of Program
Terminal
indicates Input or Output
e.g. (input):
Insert your password
Read temperature
Input / Output Get resistor’s value
e.g. (Output):
Print receipt of payment
Display current GPA
NAS SEM 1 2020/2021 26
FLOWCHART: SYMBOL & DESCRIPTION
indicates computation or data manipulation
e.g.:
Process
Set timer = 5 seconds
Given resistor’s value = 10 000 ohms
Initial n = 3
Assume j = 0
Calculate sum = a+b+c
Compute average = sum/n
Find voltage, V = I/R
NAS SEM 1 2020/2021 27
FLOWCHART: SYMBOL & DESCRIPTION
Specific for for statement (Chapter 3)
Indicates the initial, final and increment values of a loop
e.g.: Find sum of ten (10) integers.
Loop
Gives you an idea:
- iterates for 10 times
- start (initial) value to iterate could be 0 or 1
- stop (final) value could be 9 or 10
- if the increment value is 1
NAS SEM 1 2020/2021 28
FLOWCHART: SYMBOL & DESCRIPTION
indicates a decision point in the algorithm (Chapter 3)
e.g.:
Decision
To turn ON the LED, the LDR reading is 0 (dark).
Turn ON the Fan if temperature reading is 28ºC.
Otherwise, turn it OFF.
Gives warning “DANGER”, if speedometer reads
above 300kmph, warning “ALERT” if it reads above
100kmph and not more than 300kmph and no
warning if it reads not more than 100kmp.
NAS SEM 1 2020/2021 29
LDR: Light Dependent Resistor
FLOWCHART: SYMBOL & DESCRIPTION
to indicates the flow.
Arrows
Indicates continuation of flow on the same
On-page connector page.
Indicates continuation of flow on the another
page. Off-page connector
NAS SEM 1 2020/2021 30
FLOWCHART FOR EXAMPLE : SLIDE 23 &
24 Case study 2
Case study 1 Begin
Begin Print “Enter your age”
Display “Hi Read age
yes Print “You can
End if age
>= 18 vote”
no
Print “You can’t vote !”
End
NAS SEM 1 2020/2021 31
SIMPLE EXAMPLE IN C++
Problem : Write a program that evaluates the arithmetic expression A= B+ C -
7. Assign an arbitrary value to B and C inside the program. Then, print A.
NAS SEM 1 2020/2021 32
SIMPLE EXAMPLE IN C++ (CONT…)
This correspond to Flowchart
pseudocode instruction
Begin
Begin
Set B to 10 Set A = 10
Set C to 5 Set B = 5
Calculate A = B + C – 7
Calculate,
( or Set A to B plus C minus 7)
A=B+C-7
Print “The value of A is”, A
End Print “ The value of A
is”, A
End
EXERCISE
NAS SEM 1 2020/2021 34
EXERCISE A
Design the algorithm using flowchart and
pseudocode for the following problems:
(a) Calculate the multiplication of two integer
numbers.
(b) Compute the total value of four floating point
numbers
NAS SEM 1 2020/2021 35
EXERCISES B
1) Write an algorithm (pseudocode & flowchart)
to read three (3) input of test marks, calculate
the average and display the result.
2) Additional to problem( 1), if the result is 60
and above, display the mark is “PASSED”,
otherwise display the mark is “FAIL”
NAS SEM 1 2020/2021 36
REVIEW QUESTIONS
1. What is computer programming language?
2. Discuss three types of programming errors.
3. Why algorithm is important? How can we
represent it in the form od logical sequences?
NAS SEM 1 2020/2021 37
Problem Solving Questions
Instructions:
a) Provide the first three steps of Software Development Methods (SDM) for the following
problem statements. Please take note that for the step 3 of SDM, you need to provide an
algorithm using pseudo-code and flowchart.
(6 marks)
(7 marks)
(7 marks)
NAS SEM 1 2020/2021 38
NAS SEM 1 2020/2021 39