3GL Step-Form Algorithm - Exercise 2
  Since this is a combination of two algorithms we have done before much of the work is finished. We know what processes, decisions, loops are required and almost all of the variables, we need to add one variable, a total vowel counter. We have the two original algorithms so we just need to combine them and make some refinements. The major task here is in using strategy step 3 - the refinement step.

The main refinement or change I made was to change the sense of the vowel test in step 10. The original vowel counting algorithm tested to determine is a letter was a vowel, this one tests to determine if a letter is not a vowel. This made it easier to jump around the steps that take care of incrementing the vowel counters.

      1    Set total_vowel_counter to 0
      2    Get book
      3    Open book
      4    Find next page
      5     If there is no next page go to step 18
      6    Set current_letter_position to 1
      7    Set last_letter_position to number of letters on the page
      8    Set vowel_counter to 0
      9    Read letter at current_letter_position
    10    If letter is not a vowel then go to step 13
    11    Increment vowel_counter
    12    Increment total_vowel_counter
    13    Increment current_letter_position
    14    If current_letter_position <=  last_letter_position go to step 9
    15    Display vowel_counter for current page
    16    Set vowel_counter to 0
    17    Go to step 4
    18    Display total_vowel_counter

Return to lesson
 


and may not be reproduced by any means without the written
 

This publication is copyright David Beech and Learning Systems 1997-2002
and may not be reproduced by any means without the written permission of
David Beech.
9 Wyndella Street, Tasmania, Australia


db@codelearn.com