Creating Pseudocode Algorithm
Creating Pseudocode Algorithm
Problem Statement
A worker is paid at a rate of $90.00 per day and might work up to six days a week. Write a program to accept the rate
of pay and the number of days worked. The program should then calculate and print the weekly salary paid to the
worker.
Step 1: Define the problem by outlining the variables in the input and output as well as the steps from the processing
column.
Complete this table to assist with identifying the category of your data items and their data types
Include a statement briefly explaining the purpose of the algorithm, then identify the category of your data items
(constant/variable) and declare them.
Declare constants: const nameofconstant = value
Declare variables: declare nameofvariable as datatype
Organize your command statements (input, assignment and output) in a logical manner within a block (body):
Start
<prompt/output>
<input>
<assignment> e.g. variable storing calculation ← equation
<output>
Algorithm weeklysalary
This algorithm will calculate and print the weekly salary
Declare rpay, wsalary as real
Declare daysworked as integer
Start
Print “Input the rate of pay and days worked”
Read rpay, daysworked
Step 1: Define the problem by outlining the variables in the input and output as well as the steps from the processing
column
Complete this table to assist with identifying the category of your data items and their data types
Nb. You can identify your variables from the input and output column of the IPO chart. Other data items that would be
constant can be found in the processing columns. You may also find other variables in the processing column like
those used to store the solution used to solve the final output (divide and conquer)
Step 3: Represent the above solution (Processing Column) as an Algorithm (Pseudocode/Flowchart)
Pseudocode:
Create the Header using the key term Algorithm, then an appropriate title of your choosing.
Include a statement briefly explaining the purpose of the algorithm, then identify the category of your data items
(constant/variable) and declare them.
Organize your command statements (input, assignment and output) in a logical manner within a block (body):
Start
<prompt/output>
<input>
<assignment>
<output>
Sales amount Get sales amount, tax rate Total sales after tax
Tax rate
Calculate sales tax by multiplying
tax rate by sales amount
Complete this table to assist with identifying the category of your data items and their data types
Include a statement briefly explaining the purpose of the algorithm, then identify the category of your data items
(constant/variable) and declare them.
Organize your command statements (input, assignment and output) in a logical manner within a block (body):
Start
<prompt/output>
<input>
<assignment>
<output>