Sie sind auf Seite 1von 49

Learning outcomes

Identify and use the basic tools used to aid

in the development of a solution to a problem

Use an IPO chart to designate the input,

processing, and output for a solution of a


problem

Use algorithms to develop the instructions

for the solution of a problem

Design solution using control structure


Describe the importance of internal and

external documentation

Tools to aid in program developement


1. IPO chart
2. Algorithm
A.
B.

Pseudocode
Flowchart

IPO Chart
The Input-Process-Output chart also known as

the IPO chart extends and organizes the


information in the problem analysis.

An IPO chart identifies a problem's inputs, its

outputs, and the processing steps required to


transform the inputs into the outputs.

use in the analysis stage to identify inputs,

outputs and corresponding process is the IPO


table

IPO Chart
The INPUT section contains all input data to be

processed in solving the problem.

The PROCESS section contains all processing

List of actions needed to produce the required output

The OUTPUT includes all required output as

designated by the problem and/or the user

IPO Chart
Has Three

sections:
the Input
the Processing
the Output

IPO Chart for


Payroll Problem
Input

processing

Output

Pay_rate

1.Prompt and
Get
Pay_rate

Pay

2. Calculate
Pay
3. Print Pay

4. End

IPO CHART (EXAMPLE 1)


If a human heart beats on the average of once a second, how many

times does the heart beat in a lifetime of 78 years? (use 365.25 for
days in a year). Write a program that can calculate the total heart
beats as the heart rate (beat per minute) and the lifetime are
provided by user.
IPO chart
INPUT

PROCESS

OUTPUT

heart_rate
lifetime

1.
2.
3.
4.

total_heart_beat

Prompt and get for heart_rate


Prompt and get for lifetime
Calculate total_heart_beat
Display total_heart_beat to
the screen
5. End

IPO CHART (EXAMPLE 2 )


You are required to design and write a program that will read

in a tax rate (as a percentage) and the prices of three items. The
program is to calculate the total price, before tax, of the items,
then the tax payable on those items. The tax payable is
calculated by applying the tax rate percentage to the total
price. Print the total price and the tax payable as output.
IPO chart
INPUT

PROCESS

OUTPUT

taxrate
item1
item2
item3

1. Prompt for taxrate, item1, item2, totalprice


item3
taxpayable
2. Get taxrate, item1, item2, item3
3. Calculate totalprice, taxpayable
4. Display totalprice, taxpayable
5. End

Algorithm

Algorithm is a set of instructions needed to solve


the problem.

An algorithm (instructions) must:

Be lucid, precise and unambiguous

Give correct solution in all cases

Eventually end

Must be executable one step at a time

Must be complete

Cannot assume anything

Cannot skip steps

Algorithm
Representation of algorithm:
A.Pseudocode
B.Flowcharts

Pseudocode
Pseudocode
Algorithm in simple English (All statements are

written in simple English).


Each instruction is written on a separate line.
Keywords and instructions is written from top to
bottom, with only one entry and one exit.
Groups of statements may be formed into
modules, and that group given a name. (optional)

Pseudocode
Remember all the keywords for six basic
computer operations?

One: Read, Get (Received information)


Two: Print, Write, Put, Output, Display ( Put Out
information)
Three: +, -, *, /, (). (perform arithmetic)

Four: Initialise, Set, =, Save, Store. (assign a value to


memory location)
Five: IF, THEN, ELSE. (compare two variables)

Six: DOWHILE, ENDDO. (repeat actions)

Pseudocode
One : A computer can receive information

Read student_name

Get system_date

Read number_1, number_2

Get tax_code

Pseudocode
Two : a computer can put out information

Print Program Completed

Write customer record to master file

Put out name, address, and postcode

Output total_tax

Display End of Data

Pseudocode
Three : a computer can perform arithmetic

sales_tax = cost_price * 0.10

Compute C = (F 32) * 5/9

Pseudocode
Four: A computer can assign a value to a
variable or memory location

Initialise total_price to zero

Set student_count to 0

total_price = cost_price
Store customer_num in last_customer_num

Pseudocode
Five: A computer can compare two variables
and select one of two alternate actions
IF student_attendance_status = part_time
THEN
add 1 to part_time_status
ELSE

add 1 to full_time_count
ENDIF

Pseudocode
Six: A computer can repeat a group of
actions
DOWHILE student_total < 50

Read student_record
Print student_name,
Add 1 to student_total
ENDDO

Pseudocode
Example
A Program is required to prompt the terminal operator for the maximum
and minimum temperature readings on a particular day, accept those
readings as integers, and calculate and display to the screen the average
temperature, calculated by (maximum temperature + minimum
temperature)/2
IPO Chart
Input

Process

Output

max_temp
min_temp

1.Prompt for max_temp,


min_temp
2.Get max_temp, min_temp
3.Calculate avg_temp
4.Display avg_temp
5.End

avg_temp

Pseudocode
Find_average_temperature
Prompt operator for max_temp, min_temp
Get max_temp, min_temp

avg_temp = (max_temp + min_temp)/2


Display avg_temp to the screen
END

Pseudocode example
If a human heart beats on the average of once a second, how many

times does the heart beat in a lifetime of 78 years? (use 365.25 for
days in a year). Write a program that can calculate the total heart
beats as the heart rate (beat per minute) and the lifetime are
provided by user.
Find_total_heart_beat
Prompt and get for heart_rate
Prompt and get for lifetime
total_heart_beat = lifetime * heart_rate * 60 * 24 * 365.25
Display total_heart_beat to screen
END

IPO CHART (EXAMPLE 1)


IPO chart
INPUT

PROCESS

OUTPUT

heart_rate
lifetime

1.
2.
3.
4.

total_heart_beat

Prompt and get for heart_rate


Prompt and get for lifetime
Calculate total_heart_beat
Display total_heart_beat to
the screen
5. End

Find_total_heart_beat
Prompt and get for heart_rate
Prompt and get for lifetime
total_heart_beat = lifetime * heart_rate * 60 * 24 * 365
Display total_heart_beat to screen
END

IPO CHART (EXAMPLE 2 )


You are required to design and write a program that will read

in a tax rate (as a percentage) and the prices of three items. The
program is to calculate the total price before tax of the items,
then the tax payable on those items. The tax payable is
calculated by applying the tax rate percentage to the total
price. Print the total price and the tax payable as output.
IPO chart
INPUT

PROCESS

OUTPUT

taxrate
item1
item2
item3

1. Prompt for taxrate, item1, item2, totalprice


item3
taxpayable
2. Get taxrate, item1, item2, item3
3. Calculate totalprice, taxpayable
4. Display totalprice, taxpayable
5. End

Flow Chart

Flow Chart
Find_average_temperature
Prompt and Get for max_temp
Prompt and Get for min_temp
avg_temp = (max_temp + min_temp)/2
Display avg_temp to the screen
END

Flowchart example

Start

Prompt
and get
for
heart_rate

Find_total_heart_beat
Prompt and get for heart_rate
Prompt and get for lifetime
total_heart_beat = lifetime * heart_rate * 60 * 24 * 365.25
Display total_heart_beat to screen
END

Prompt
and get
for
lifetime

total_heart_b
eat = lifetime
*
heart_rate
* 60 * 24 *
365.25

Display
total_hea
rt_beat

Stop

Designing Solutions
Using Logic Structure (Structured Theorem)
Assist programmer in writing effective error free
programs.
Possible by write the computer program by using Three
control structures

Sequential control structure


Selection control structure
Repetition control structure

Sequential Control Structure


Define as the straightforward execution of one

processing step after another


Next slide flowchart representation of sequence
control structure

1. Sequence Control Structure


Statemement a

Statemement b

Statemement c

2. Selection Control Structure


Defined as the presentation of a condition
The choices between two actions depending on

whether the condition is true or false

2. Selection Control Structure


T

F
Condition?

Statemement a

Statemement b

2. Selection Control Structure - Case


structure
another way of expressing a nested IF statement
Not an additional control structure

A structure to be a choice between multiple values

Case Structure
Case
Of
variable

Value 1

Statement_a

Value 2

Value 3

Value 4

Statement_b

Statement_c

Statement_d

3. Repetition
Defined as the presentation of a set of instruction to

be performed repeatedly
Block of statement is executed again and again until a
terminating condition occurs
Three loop structure :
FOR
WHILE
DO-WHILE

prefix

condition

FOR Loop

statement

update

stop

condition
update
T

statement
T

stop

WHILE
Loop

DO-WHILE
Loop
statement

update
F
Condition

T
stop

Internal and External Documentation


Internal documentation
Remarks written with the instructions to explain

to explain what is being done in the program.


Necessary so that program can be easily
understood by another programmer
External documentation
Manuals or help menus written about the
solutions.
For users of program

Internal documentation

internal documentation
internal documentation consists of the comments

inclede in the program.


The procedure name should convey as much of this

information as possible.
Names of variables, types, constants, and field

selectors should also be as meaningful as possible,


with a comment next to the declaration to fill in extra
information.
Example
say "index of last element on the stack" rather than
"top of stack"

External documentation
may include as a long comment right at the beginning

of the program itself


two types:
for the typical user and for someone who wants to
understand how the program works
1st, includes details of how to call the program, it
options , format of data, limitations, bugs and special
features.
other kind of ED: overview of the algorithm used int
eh program; parts of this information included in the
assignment need not be repeated.
give the reader an overview of how the program works,
so that they can understand smaller pieces of it
without having to understand each procedure.

Start
Prompt for
Block_length,
Block_width
GET for
Block_length,
Block_width
Prompt for

House_length,
House_width
Get for
House_length,
House_width
mowing_area =
(Block_length* Block_width)
(House_length*House_width)
mowing _time =
mowing_area/2

Display
mowing_time

Stop

Das könnte Ihnen auch gefallen