Initially..When Notation

Initially..when notation is a way of describing algorithms. It describes the initial value of variables and what happens when each event is triggered. This notation is particularly useful in applet programming.

This example from the 2015 Tasmanian Computer science exam is an algorithm for calculating the cost of a computer system based on the specifications.

Initially

set more_memory = “No”
set power_processor = “No”

When text is entered into “Want more memory?” TextField

set more_memory to value in “Want more memory” TextField
if power_processor is “No” and more_memory is “Yes”

set more_memory to “No”

display “If the more powerful process is not selected more memory cannot be selected.”
display “More Memory?” more_memory

When text is entered into “Want power processor?” TextField

set power_processor to value in “Want power processor” TextField
if power_processor is “No” and more_memory is “Yes”

set power_processor to “Yes”

display “If the more memory is selected the more powerful process must be selected.”
display “More Memory?” more_memory
display “Power Processor?” power_processor

When the “Calculate” button is pressed

set cost = 400 if more_memory is “Yes”
set cost = cost + 80 if power_processor is “Yes”
set cost = cost + 200
display “Cost of computer: $” cost

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License