0% found this document useful (0 votes)
130 views

Chapter 3

The document discusses tools used in program development such as IPO charts, algorithms represented through pseudocode and flowcharts, and control structures for designing solutions. IPO charts are used to identify the inputs, processes, and outputs of a problem. Pseudocode and flowcharts represent algorithms through step-by-step English instructions and graphical representations respectively. Control structures like sequence, selection, and repetition are used to effectively write programs. Internal documentation comments the code while external documentation provides manuals for users.

Uploaded by

Neshvin Nair
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

Chapter 3

The document discusses tools used in program development such as IPO charts, algorithms represented through pseudocode and flowcharts, and control structures for designing solutions. IPO charts are used to identify the inputs, processes, and outputs of a problem. Pseudocode and flowcharts represent algorithms through step-by-step English instructions and graphical representations respectively. Control structures like sequence, selection, and repetition are used to effectively write programs. Internal documentation comments the code while external documentation provides manuals for users.

Uploaded by

Neshvin Nair
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Learning outcomes

Identify and use the basic tools used to aid


Use an IPO chart to designate the input,

in the development of a solution to a problem processing, and output for a solution of a problem for the solution of a problem

Use algorithms to develop the instructions

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 1.Prompt and Get pay_rate 2. Calculate pay 3. Print pay Output

pay_rate

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 heart_rate lifetime PROCESS 1. 2. 3. 4. Prompt and get for heart_rate Prompt and get for lifetime Calculate total_heart_beat Display total_heart_beat to the screen 5. End OUTPUT total_heart_beat

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 taxrate item1 item2 item3 PROCESS OUTPUT

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 max_temp min_temp Process 1.Prompt for max_temp, min_temp 2.Get max_temp, min_temp 3.Calculate avg_temp 4.Display avg_temp 5.End Output 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 heart_rate lifetime PROCESS 1. Prompt and Get for heart_rate 2. Prompt and Get for lifetime 3. Calculate total_heart_beat 4. Display total_heart_beat to the screen 5. End OUTPUT total_heart_beat

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 taxrate item1 item2 item3 PROCESS 1. Prompt for taxrate, item1, item2, item3 2. Get taxrate, item1, item2, item3 3. Calculate totalprice, taxpayable 4. Display totalprice, taxpayable 5. End OUTPUT totalprice taxpayable

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
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

Start

Prompt and Get for heart_rate

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
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 Value 2 Value 3 Value 4

Statement_a

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

WHILE Loop

statement T

stop

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

Extra Exercise 1
A program is required to read from the screen the length and width of a rectangular house block, and the length and width of the rectangular house that has been built on the block. The algorithm should then compute and display the mowing time required to cut the grass around the house, at the rate of 2 square meters per minute. Design the IPO chart and construct pseudocode and flowchart for this program.

You might also like