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

Introduction to Programming - 2 ACTIVITY

The document outlines the process of problem-solving and program design in programming. It details the steps involved, including defining the problem, proposing solutions, determining the most efficient solution, developing algorithms, and testing the solution. Additionally, it provides examples of problem statements and Input-Processing-Output (I-P-O) charts to illustrate the concepts.

Uploaded by

Unique McDonald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Introduction to Programming - 2 ACTIVITY

The document outlines the process of problem-solving and program design in programming. It details the steps involved, including defining the problem, proposing solutions, determining the most efficient solution, developing algorithms, and testing the solution. Additionally, it provides examples of problem statements and Input-Processing-Output (I-P-O) charts to illustrate the concepts.

Uploaded by

Unique McDonald
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

PROBLEM SOLVING AND

PROGRAM DESIGN
INTRODUCTION TO PROGRAMMING 2
WHAT IS A PROBLEM?
• A problem is a discrepancy between what is
required and what exists.

Problems can range from simple to complex. A


simple problem usually involves only one main
task such as computing the tax on an item.
Steps To Solve A Problem
1. Define the problem – define the problem clearly to ensure
there is no uncertainty or ambiguity. Write the problem
clearly with as many important details as possible
- aim is to understand the problem
- starts with a description of the problem in narrative form
- an I-P-O chart is used to break problem down into its
component parts
- what needs to be done to solve the problem is
determine during this step
I-P-O Chart
• An Input Processing Output chart is a table
that shows the inputs, the processing steps
and the outputs related to a particular
problem. It is also known as a defining
diagram and is presented using a 3-column
table.
INPUT PROCESSING OUTPUT

What is given All the instructions The expected


that must be results
executed to
transform what is
given into the
expected results
Steps To Solve A Problem
2. Propose and analyse solutions– take the
problem and break it into manageable
components.
- considers alternative solutions to the
problem
- analyses each proposed solution
Steps To Solve A Problem
3. Determine the most efficient solution
- This step evaluates the solutions developed in
the previous step and determines which one is
almost efficient
Steps To Solve A Problem
4. Develop and represent the algorithm.
- An algorithm is a set of instructions that if
followed in sequence will lead to a solution for
the problem
- Algorithm may be developed using a
combination of sequential, conditional and
looping statements
- Algorithm may be represented using
pseudocode or a flowchart
Steps To Solve A Problem
5. Test and validate the solution
- final step in the program design process
- Pseudocode/flowchart is tested for
correctness using a trace table
- if the algorithm produces correct results
for a set of carefully test data then the
design is deemed valid and program
implementation may commence
Problem Statement
You have put some items into a shopping basket
at a supermarket and you want to pay for
them. The items are a tube of toothpaste, 2kg
sugar, and a loaf of bread

Poor Statement: Calculate the price


Strong Statement: Add the prices of
three to get a total
price
Input/Processing/Output Chart
A table that groups the different instructions and
statements according to the type of
component.

There are three components – Input, Processing


and Output
• INPUT – data that you will need in order to
calculate or solve a problem:
– e.g. enter the prices of three items

• PROCESSING – statements that tell you what


you needs to be done to solve the problem
– e.g. add the marks received for a test out of 100
for student 1 if the total is 50 marks or over,
display “Pass”. If the total is under 50, display
“fail”. Repeat for student 2.
• Output – statements contain the solution or
end result that you require.
– e.g. Add the marks received for a test out of 100
and show the total. If the total is 50 marks or
over, display “Pass”. If the total is under 50,
display “Fail”.
Problem Description
• Susan owns and runs ‘BVI Boat Hire’ that
specialises in renting out boats. She needs a
program that reads in the number of hours
that a boat is rented, calculates the total cost
and prints out the total cost.
Solution
Input Processing Output
Number of hours Set price per hour Total cost

Read in the number of


hours

Calculate the total cost

Print out the total cost


Problem Statement
• Calculate the weight of two persons
• INPUT PROCESSING
OUTPUT
Weight of total weight= weight display
the
person 1 of person 1 + weight total weight
of person 2
Weight of
person 2
Activity 1
• Calculate and show the average height of
three students. If the average is 165cm or
over, display the message “TALL!” and the
average height.
Activity 2
• Create an I-P-O chart to show the following:
- Calculate and show the average height of
three students. If the average is 165cm
or over, display “Tall” and the average
height
Activity 3
• Create an I-P-O chart to illustrate the
following:

-Calculate the average temperature of


any given day. Display Average
temperature.
END OF LESSON!

You might also like