Algorithm : Rogue Values

A sequence of inputs may continue until a specific value is input. This value is called a rogue value and must be a value that would not normally arise.

A rogue value lets the computer know that a sequence of input values has come to an end.

Example

A number of marks is to be input (terminated by a rogue value of -1). How many of them are over 50?

Note that -1 is a value which would not arise.

counter = 0
repeat
  input (mark)
  if mark > 50 then
    add 1 to counter
  end if  
until mark = -1
output(counter)

You will need to be careful that you do not 'process' the rogue value!
The general 'shape' of an algorithm which uses a rogue value will be...

counter = 0
repeat
  input (item)
  if item is not the rogue value then
    process item
  end if  
until item = rogue value
output(counter)