Creating Pseudocode Algorithms
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.
Input Processing Output
Rate of pay Get rate of pay, number of days Weekly salary
Number of days worked worked
Calculate Weekly salary by
multiplying rate of pay by number
of days worked
Display Weekly salary
Complete this table to assist with identifying the category of your data items and their data types
Identifier Variable or Constant Identifier Name Data Type or Value
Rate of pay variable rpay real
Number of days worked variable daysworked integer
Weekly salary variable wsalary real
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)
Integer - negative/positive whole number e.g. 1, -5, 100, 10
Real - decimal numbers e.g. 0.10, 1.15, 5.00
Character - single letters or symbols e.g. W, $, %, &
String - sequence of characters - words, e.g. boy, Kellee, A001
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.
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>
Terminate the algorithm with the key word: Stop
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
wsalary ← rpay * daysworked
Print “The weekly salary is $”, wsalary
Stop
Problem Statement
Each Playstation IV game has a tax of 10% added to its cost to calculate the final price. Write a pseudocode algorithm
to accept from the user the initial cost of the game. Calculate and output the final price.
Step 1: Define the problem by outlining the variables in the input and output as well as the steps from the processing
column
Input Processing Output
Initial cost Get initial cost Final price
Calculate tax amount by multiplying
tax (10%) by initial cost
Calculate Final price by adding tax
amount to initial cost
Display Final price
Complete this table to assist with identifying the category of your data items and their data types
Identifier Variable or Constant Identifier Name Data Type or Value
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>
Terminate the algorithm with the key word: Stop
Problem Statement
User asks you to develop a program to calculate total sales after sales tax. User will provide the sales amount and the
tax rate. Print the total sales after tax.
The calculation must be done in two steps as shown below:
(HINT: What is the right order of operation?)
Total Sales = Sales Amount + Sales Tax
Sales Tax = Tax Rate * Sales Amount
Input Processing Output
Sales amount Get sales amount, tax rate Total sales after tax
Tax rate
Calculate sales tax by multiplying
tax rate by sales amount
Calculate total sales after tax by
adding sales tax to sales amount
Display Total sales after tax
Complete this table to assist with identifying the category of your data items and their data types
Identifier Variable or Constant Identifier Name Data Type or Value
Sales Amount variable samt real
Tax rate variable trate real
Sales tax variable stax real
Total sales after tax variable tsales real
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>
Terminate the algorithm with the key word: Stop