Pseudocode pt1
Pseudocode pt1
Design
Specific Objectives
Students should be able to:
Represent algorithms in the form of
• pseudocode
Prepared by Ms A. Cole
Pseudocode algorithm
Pseudocode is similar to real programming language
Assignment statements
Control structure
o Sequencing
o Selection
o Iteration/Repetition
Input & output statement
+, -, *, /, %
• START
READ yob
READ currentyear
STOP
Example
Write an algorithm in pseudocode to prompt for and accept the customer’s
previous and current meter readings. The algorithm should compute the
units of electricity consumed this month and also compute the amount to
pay. The fuel charge is fixed at $12.50 per kWh and the customer charge at
$125. The bill is computed using the formula:
amount_to_pay = (units_used * fuel charge) + customer_charge
The program should print the words “Please pay this amount =>” followed
by the amount to be paid, print the farewell statement “National
Electricity….Reliable service since 1975” as the last line of the bill.
START
PRINT “Enter the customer’s current meter reading”
READ current_reading
PRINT “Enter the customer’s previous reading”
READ previous_reading
STOP
Put your brain to
work!!
Write pseudocode algorithms to solve the following:
• James would like to secure his pool from public access. He was encouraged by
his friends to use diamond fence around it. James gave you the length and the
width of the pool and ask you to compute and print the length of fencing
required.
• Kara wants to buy a $350 costume for the upcoming carnival. She decides to
sell some cakes in order to raise the funds for the costume. Kara’s friend
ordered some cakes. Accept the quantity of cakes ordered, then calculate and