Professional Documents
Culture Documents
IT-Notes - Jan11 (AutoRecovered) (AutoRecovered)
IT-Notes - Jan11 (AutoRecovered) (AutoRecovered)
Objectives
Define the terms problem and problem solving
Outline and explain correctly each step in the problem-solving phase
Illustrate by decomposing large everyday problems into smaller tasks by using the dive and
conquer approach.
A problem is anything that needs to be solved or a task that needs to be accomplished. The steps in
problem solving
Groupwork Activity
Your younger sister is having her 16th birthday party and the caterer is unable to complete the order due
to being sick. You volunteer to help out with the cake.
OR
1. Define algorithm
It is a finite sequence of well-defined instructions typically used to solve a class of specific
problems.
Or
If num1>num2 then
Lnum1←num1
Endif
If num2>num1 then
lnum←num2
Eg) num1←5
num2←23
IF 5>23 then
lnum←5
endif
IF 23>5 then
lnum←23
endif
PRINT 23
2. To calculate the discount price of a computer. If the computer costs more than $2,000, the discount
is 17%. If not, it is 14%. Print the original price, discount and the price after the discount.
4. A customer pays a monthly fee of $37.50 for telephone service and $3.50 per minute for long
distance calls. Input the number of minutes for long distance calls. Calculate and print the total
bill.
1. To read a number P. If the number is greater than 50. It should add 20 to P. If not, it
should subtract 20 from P. Print the result.
The “IF Statement” is also called Selection, Conditional or Decision-Making. There are some examples
which we will use.
ENDIF Statement
Statement
ENDIF
IF A>B THEN
Lnum ← A
Lnum ← B
ELSEIF C ← Lnum
ENDIF
Information Technology
February 1, 2022
Problem Solving and Programme Design
Literals
Literals are constants that are written literally as itself rather than a value.
Examples- “The average is”, “The smallest number is”, “The highest grade is”.
Literals are normally used with the input/output instructions that appear as a message for the
user (prompt). The messages /prompts make the programme user friendly.
Data Type
Data type indicate or tells the type of data a variable can store. A variable can store the
following Data Types:
Information Technology
February 3, 2022
Problem Solving and Programme Design
Algorithm Pseudocode
This algorithm closely resembles the language instructions that computers follow.’
Algorithm Student’s_Data
Start
Accept Name
Accept age
Stop
Write an algorithm pseudocode to prompt a user to enter their first and last names. Output a
welcome message that says “Welcome to our world!” with the names after it. The message must be a
constant.
Algorithm Greetings
Const
Message= “welcome to our world”
Var
Firstname, Lastname as string
Start
Print (“Please enter your first name”)
Imput (Firstname)
Print (“please enter your last name”)
Input (Lastname)
Print
Print(message,”sp”, firstname, “sp”, lastname)
Algorithm TotalOfNumbers
{Finding the total of 3 numbers}
Var
Num1, Num2, Num3, Total as integer
Start
Total = 0
Print (”Please enter 3 numbers”)
Input (Num1, Num2, Num3)
Total= Num1 + Num2 + Num3
Print (“The answer is:”, Total)
Stop
Initialization Of Variables
Variables that are used as counters or to store totals should always be assigned an initial value of 0
before being incremented. This ensures that the variables are cleared of any values may have been
assigned in a previous execution of the programme. Initialization usually comes right after Start.
Algorithm TotalOfNumbers
{Finding the total of 3 numbers}
Var
Num1, Num2, Num3, Total as real
Start
Total = 0
Print (”Please enter 3 numbers”)
Input (Num1, Num2, Num3)
Total= Num1 + Num2 + Num3
Print (“The answer is:”, Total:6:2)
Stop
Information Technology
February 3, 2022
Problem Solving and Programme Design
Algorithm Pseudocode
(9 × c)
Calculate a temperature in Celsius to Fahrenheit using the formula F= + 32.
5
Algorithm Celcius_to_Fahrenheit
Var
Start
FarTemp = 0
Input CelTemp
FarTemp= (9*CelTemp/5) + 32
GCT is 15% . Read the prices of three items. Calculate the total price of the items before tax. Calculate the tax
payable. Output the total price before tax, tax payable and overall price (all inclusive). Use prompts.
Prices_Algorithm
{To calculate the tax payable, the total price of items before tax and the overall price}
Const
GCT= 0.15
Var
PBTax, Tax, OPrice, Price1, Price2, Price3 as real
Start
Tax 0
PBTax 0
OPrice 0
Information Technology
February 24, 2022
Problem Solving and Programme Design
Algorithm Flowchart
Objectives
Define the term flow chart
State the rules for creating flow charts
Identify flow chart symbols
Explain the purpose of the flowchart symbols
Create flowchart algorithms for given problems
A flowchart is a diagrammatic representation of an algorithm. A flowchart can be helpful for both writing
programmes and explaining the programme to others.
To make sure the flowchart works, you need to follow a few basic construction rules
Each flowchart must have and only one subject
The flow of control must always enter an object from the top
The flow of control must always leave an object from the bottom (except for decision objects,
which allow the flow of control to leave the side)
The flow of control must not split. You can use decision objects to give the flow of control a
choice of paths to flow, but it can only follow one of these paths
The no-go cursors used to show you where you cannot drop objects or complete links.
Start