Академический Документы
Профессиональный Документы
Культура Документы
Development
CT010-3-1
Problem Solving Using
Programmed Solutions
Prepared by: FSK First Prepared on:09 th August 2005 Last Modified on:08th September 2005
Quality checked by: GTK
Copyright 2005 Asia Pacific University College of Technology and Innovation
Problem Solving
Learning Outcomes
At the end of this topic, you should be able
to:
Define the steps in developing a
program
Define a problem
Outline a solution using algorithm
Problem Solving
Key Terms
If you have mastered this topic, you should
be able to use the following terms correctly in
your assignments and exams:
Program
Programming Language
Algorithm
Pseudocode
Flowchart
Structured Programming
Modular
Problem Solving
Problem Solving
Problem solving (within the context of
developing programs) refers to analysing
a problem with the intention of deriving a
solution for the problem.
Problem Solving
What is a Program?
A program is a collection of computer
instructions or operations which are
grouped together in a logical manner to
accomplish a given task.
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
12 ft = 4 yds
18 ft = 6 yds
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Flowchart
A flowchart is a pictorial representation of
the logical steps it takes to solve a
problem.
And because almost every program
involves the steps of input, processing,
and output; flowcharts need some way to
separate visually these three steps.
When you create a flowchart, you draw
geometric shapes around the individual
statements and connect them with arrows.
CT010-3-1 Fundamentals of Software Development
Problem Solving
Flowchart
The following are the commonly used
symbols for drawing program flowcharts.
off-page
connect
or
terminator
process
storage
Problem Solving
Flowchart
The following are the commonly used
symbols for drawing program flowcharts.
decision
making
document
input/output
connector
arrowheads
Problem Solving
Flowchart
Begin
Read Amount
YES
Amount>20.00?
Calculate
Actual=Amount * 0.80
Calculate
Actual=Amount
End
CT010-3-1 Fundamentals of Software Development
NO
Problem Solving
Pseudocode
Pseudocode is an English-like
representation of the logical steps it takes to
solve a problem.
Pseudo is a prefix that means false, and to
code a program means to put it in a
programming language; therefore
pseudocode simply means false code
Problem Solving
Pseudocode
The following three statements constitute a
pseudocode representation of number
doubling problem:
get NUMBER
compute ANSWER as NUMBER times 2
print ANSWER
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Problem Solving
The first stage to problem solving is to obtain
a clear understanding of the problem.
Take a look at the following problem.
Problem
You are required to design a complete
system which will enable the sum of two
values to be calculated.
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
To grapple with this problem, we have to
understand the problem from the human
perspective.
A question to ask yourself is this:
How Would You Calculate the Sum of
Two Values?
Problem Solving
Problem Solving
As the computer is also a device similar to
the way in which the human brain functions,
the process of calculating the sum of two
values can also be easily performed by the
computer.
=
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
Processing
(Brains)
Input
Output
Problem Solving
Problem Solving
Output Device
CPU
(Brains)
Input Device
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
Let us assume we are interested in
calculating the sum of 5 and 10.
5
Processing
10
5 + 10 = 15
15
Input
Output
CT010-3-1 Fundamentals of Software Development
Problem Solving
Problem Solving
As shown previously, the example values
(5 and 10) have been specified explicitly.
As the brain is flexible enough in
calculating a wide range of numbers, the
two input values have to be generalised.
Problem Solving
Problem Solving
Notice that instead of using specific
numbers, variables are used to represent
these values.
Value2
Value1
Sum = Value1 + Value2
Sum
Problem Solving
Problem Solving
Problem Solving
Problem Solving
Algorithm Development
The basic mathematical operators used in
algorithms are as follows:
+
addition
-
subtraction
multiplication
division
assignment
()
Problem Solving
Algorithm Development
Example of an algorithm (using pseudocodes)
which can be used to carry out the tasks
outlined is as follows:
1)
Sum = 0
2)
3)
Calculate
Sum = Value1 + Value2
4)
Display Sum
Problem Solving
Review Exercise
Problem
You are required to develop a program to
calculate the total and average of 3
numbers and display the total and average
on the monitor screen.
Problem Solving
Enter 3 numbers.
Calculate the total and average of the
3 numbers.
Display the total and average of the 3
numbers.
Problem Solving
Problem Solving
Next Lesson
Introductory Programming Skills
Using the Integrated Development Environment
What is Java?
Why Java is popular?
Java and the Internet
The structure of a program
A simple Java program
How program code is executed by a computer
A look at JDK
Applets and Applications
API Documentation
CT010-3-1 Fundamentals of Software Development
Problem Solving