Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 48

COURSE - Problem Solving and

Programming Concepts (CSC3100)

TOPIC 3 – Problem Solving Techniques

 Software Development Process


 Concept and organization of problem
solving
 Programming and implementation

1
Learning Outcomes
• At the end of this topic, student should be able to:

– Analyse problem and identify the problem requirement


(C4)
– Using the correct notation in developing flowchart (C3)
– Use a problem analysis chart to consolidate data for a
problem. (C3, CTPS)

ASSESSMENT 1, FINAL EXAM

2
Software Development Process

3
Requirement Specification
A formal process that seeks to understand
Requirement
Specification
the problem and document in detail what
the software system needs to do. This
System phase involves close interaction between
Analysis
users and designers.
System
Design

Implementation

Testing

Most of the examples in this book are simple,


and their requirements are clearly stated. In Deployment

the real world, however, problems are not


well defined. You need to study a problem Maintenance
carefully to identify its requirements.
4
System Analysis
Requirement
Specification Seeks to analyze the business
process in terms of data flow, and
System
Analysis to identify the system’s input and
output.
System
Design

Implementation

Part of the analysis entails modeling Testing

the system’s behavior. The model is


Deployment
intended to capture the essential
elements of the system and to define
Maintenance
services to the system.
5
System Design
Requirement
Specification
The process of designing the
system’s components.
System
Analysis

System
Design

Implementation

Testing

This phase involves the use of many levels


Deployment
of abstraction to decompose the problem into
manageable components, identify classes
and interfaces, and establish relationships Maintenance
among the classes and interfaces.
6
IPO
Requirement
Specification

System
Analysis Input, Process, Output

System
Design

Implementation

Testing

The essence of system analysis and design is input,


process, and output. This is called IPO. Deployment

Maintenance

7
Implementation
Requirement The process of translating the
Specification
system design into programs.
System Separate programs are written for
Analysis
each component and put to work
System together.
Design

Implementation

Testing
This phase requires the use of a
programming language like Java. Deployment
The implementation involves
coding, testing, and debugging. Maintenance

8
Testing
Requirement
Specification Ensures that the code meets the
requirements specification and
System
Analysis weeds out bugs.
System
Design

Implementation

Testing
An independent team of software
engineers not involved in the design Deployment
and implementation of the project
usually conducts such testing. Maintenance

9
Deployment
Requirement
Specification Deployment makes the project
available for use.
System
Analysis

System
Design

Implementation

Testing

For a Java program, this means Deployment


installing it on a desktop or on the
Web. Maintenance

10
Maintenance
Requirement
Specification Maintenance is concerned with
changing and improving the
System
Analysis product.
System
Design

Implementation

Testing
A software product must continue to
perform and improve in a changing Deployment
environment. This requires periodic
upgrades of the product to fix newly Maintenance
discovered bugs and incorporate changes.
11
Concept and organization of problem
solving

Solving problem by computer undergo two phases:


– Phase 1:
• Organizing the problem or pre-programming
phase.

– Phase 2:
• Programming phase.

12
Pre-Programming Phase
• This phase involves:
1. Analyzing the problem – Problem Analysis
Chart
2. Developing the Input-Process-Output (IPO)
Chart.
3. Writing the algorithms.
• Drawing the flowchart, or
• Pseudocode

13
Pre-Programming Phase
(1) Analyzing the Problem

Understand requirements:
a. The given data
b. The required results
c. The processing that is required in the
problem
d. A list of solution alternatives
Problem Analysis Chart
Problem Analysis Chart for the
Payroll Problem
Exercise -Problem 1
• Write a Problem Analysis Chart (PAC) to
convert the distance in miles to kilometers
where 1.609 kilometers per mile.

17
Problem 2
• Write a Problem Analysis Chart (PAC) to find an
area of a circle where
area = pi * radius * radius

18
Problem 3
• Write a Problem Analysis Chart (PAC) to compute and
display the temperature inside the earth in Celsius and
Fahrenheit. The relevant formulas are
Celsius = 10 x (depth) + 20
Fahrenheit = 1.8 x (Celsius) + 32

19
Pre-Programming Phase
(2) Developing the Input Process Output (IPO)
Chart
– Extends and organizes the information in the Problem
Analysis Chart.
– It shows in more detail what data items are input,
what are the processing or modules on that data, and
what will be the result or output.

20
Developing IPO Chart
• Has four sections:
– Input
• Contains all input data from the problem analysis chart
– Processing
• Contains all processing, evident and implied, from problem
analysis chart
– Module/method Reference
• Contains number for method reference
– Output
• All required output as designated by the problem and/or the
user

21
The IPO Chart for the Payroll
Problem

0-22
Exercise
From PAC chart, write an Input Process Output (IPO) for :

– Problem 1: To convert the distance in miles to kilometers where 1.609


kilometers per mile.
– Problem 2: To find an area of a circle where
– area = pi * radius * radius
– Problem 3: To compute and display the temperature inside the earth in
Celsius and Fahrenheit. The relevant formulas are
Celsius = 10 x (depth) + 20
Fahrenheit = 1.8 x (Celsius) + 32

23
Pre-Programming Phase
(3) Writing the Algorithm using Flowcharts
– Flowchart is the graphic representations of the
individual steps or actions to implement a particular
module.
– The flowchart can be likened to the blueprint of a
building. An architect draws a blueprint before
beginning construction on a building, so the
programmer draws a flowchart before writing a
program.
– Flowchart is independent of any programming
language.

24
Pre-Programming Phase
– Flowchart is the logical design of a program.
– It is the basis from which the actual program
code is developed.
– Flowchart serves as documentation for computer
program.
– The flowchart must be drawn according to definite
rules and utilizes standard symbols adopted
internationally.
– The International Organization for Standardization
(IOS) was the symbols shown below (You can draw
the symbols using ready-made flowcharting template):

25
Flowchart Symbols

0-26
Flowchart Symbols

0-27
Flowchart Symbols

0-28
Flowchart Symbols

0-29
The Flowchart for the Payroll
Problem
start

Read Hours, PayRate

Pay = Hours * PayRate

Print Pay

end
0-30
Exercise
Draw a flowchart

– Problem 2: To find an area of a circle where


– area = pi * radius * radius
– Problem 3: To compute and display the temperature inside the earth in
Celsius and Fahrenheit. The relevant formulas are
Celsius = 10 x (depth) + 20
Fahrenheit = 1.8 x (Celsius) + 32

32
Pre-Programming Phase
(4) Writing the Algorithm using Pseudocode
– Pseudocode means an imitation computer code.
– It is used in place of symbols or a flowchart to
describe the logic of a program. Thus, it is a set of
instructions (descriptive form) to describe the logic of
a program.
– Pseudocode is close to the actual programming
language.
– Using the Pseudocode, the programmer can start to
write the actual code.

33
Algorithms for the Payroll Problem
start
Algorithm:

Start
Read Hours, PayRate Read Hours, PayRate
Pay = Hours * PayRate
Print Pay
End
Pay = Hours * PayRate

Print Pay

end

34
Problem 1
Construct an algorithm to convert the distance in
miles to kilometers where 1.609 kilometers per
mile.

Start
Read miles
km = 1.609 * miles
Print km
End
Problem 2
Construct an algorithm to find an area of a
circle where area = pi * radius * radius
Start
Read radius
area = 3.14 x radius x radius
Print area
End
Problem 3
Construct an algorithm To compute and display the temperature
inside the earth in Celsius and Fahrenheit. The relevant formulas are
Celsius = 10 x (depth) + 20
Fahrenheit = 1.8 x (Celsius) + 32
Algorithm Tracing
• An algorithm trace is a method for hand simulating the execution of your code
in order to manually verify that it works correctly before you compile it. It is
also known as a "desk check”.

• Step 1: Number each executable statement in your pseudocode or source code.

• Step 2: Draw a table with each variable in the program shown at the top of a
column. Draw a column for Statement number on the left and a column for
Output (if appropriate) on the right.

• Step 3: Starting with statement 1, simulate the action the computer will take
when it executes each statement. Draw one statement per row. In the appropriate
column, write the value that is assigned to the variable (or boolean expression).
Algorithm Tracing
• Step 1: Number each executable statement in
your pseudocode or source code.

1. Start
2. Read Hours
3. Read PayRate
4. Pay = Hours * PayRate
5. Print Pay
6. End
Algorithm Tracing
• Step 2: Draw a table with each variable in the
program shown at the top of a column. Draw a
column for Statement number on the left and a
column for Output (if appropriate) on the right.

1 stmt Hours PayRate Pay


2
3
4
5
6
Algorithm Tracing
• Step 3: Starting with statement 1, simulate the action the computer
will take when it executes each statement. Draw one statement per
row. In the appropriate column, write the value that is assigned to
the variable (or boolean expression).

10 3.5
1 stmt Hours PayRate Pay

2 2 10
3 3 3.5
4 4 35
5 5 Display Pay

6 6 end
Programming or Implementation
Phase
• Transcribing the logical flow of solution steps in flowchart
or algorithm to program code and run the program code
on a computer using a programming language.
• Programming phase takes 5 stages:
• Coding
• Compiling
• Debugging
• Run or Testing
• Documentation and maintenance

42
Programming or Implementation
Phase
• Once the program is coded using one of the
programming language, it will be compiled to ensure
there is no syntax error.
• Syntax-free program will then be executed to produce
output and subsequently maintained and documented for
later reference.

43
CODING

COMPILE THE PROGRAM

MAKE CORRECTION

NO SYNTAX
ERROR

EXECUTE OR RUN

NO LOGIC
ERROR

DOCUMENTATION OR
MAINTENANCE
Programming Phase: Coding
– Translation or conversion of each operation in the flowchart or
algorithm (pseudocode) into a computer-understandable
language.
– Coding should follow the format of the chosen programming
language.
– Many types or levels of computer programming language such
as:
– Machine language
– Symbolic language or assembly language
– Procedure-oriented language
– The first two languages are also called low-level programming
language. While the last one is called high-level programming
language.

45
Programming Phase: Compiling
– Compiling is a process of a compiler translates a
program written in a particular high–level programming
language into a form that the computer can execute.

– The compiler will check the program code also known


as source code so that any part of the source code
that does not follow the format or any other language
requirements will be flagged as syntax error.

– All syntax errors must be corrected before you execute


and test your program.
46
Debugging

– Debugging is a process of correcting any error during


compiling or running.

– An error is called a bug.

– You will find and correct syntax errors when you enter your
program into the computer.

– You can find and correct most logic errors during the
problem-solving process.

– The debugging process is continued until there is no more


error in the program.
Programming Phase: Run or
Testing
– The program code that contains no more error is
called executable program. It is ready to be tested.
– When it is tested, the data is given and the result is
verified so that it should produced output as intended.
– Though the program is error free, sometimes it does
not produced the correct result. In this case the
program faces logic error.
– Incorrect sequence of instruction is an example that
causes logic error.

48
Programming Phase:
Documentation and Maintenance
– When the program is thoroughly tested for a substantial period
of time and it is consistently producing the right output, it can be
documented.
– Documentation is important for future reference. Other
programmer may take over the operation of the program and the
best way to understand a program is by studying the
documentation.
– Trying to understand the logic of the program by looking at the
source code is not a good approach.
– Studying the documentation is necessary when the program is
subjected to enhancement or modification.
– Documentation is also necessary for management use as well
as audit purposes.

49

You might also like