CIS-2730 Homework #3: Character Counting

Due: Wednesday, February 4, 2015

  1. Continue reading Chapter 2 in the text.

  2. Prepare a branch for this assignment in the cis-2730 repository. Here are the necessary commands again for easy reference. Make a note of these commands (if you haven't memorized them yet!). I won't bother specifying them in future assignments.

            $ git status            # See what branch you're on and if you have uncommited changes. 
            $ git commit -a -m "message..." # Only if you need to commit outstanding changes.
            $ git checkout master   # Be sure you are on the master branch.
            $ git pull              # Get any updates.
            $ git branch hw03       # Create a branch for this homework.
            $ git checkout hw03     # Switch to the new branch.
  3. This assignment builds on your practice in Lab #3 with filter programs. In particular you'll be modifying filter.adb again. Introduce the following declarations into the declarative part of procedure Filter

            subtype Lowercase_Type is Character range 'a' .. 'z';
            type Counters_Type is array(Lowercase_Type) of Natural;

    Notice that arrays of type Counters_Type are indexed by characters, not integers. Also create an array of counters using Counters_Type and initialize it to all zeros using an array aggregate with others.

  4. Modify the program so that it counts how many times each letter occurs in the input. It should ignore non-letters and it should treat upper and lowercase letters the same way. Use functions from package Ada.Characters.Handling to classify characters and to transform uppercase letters to lowercase before using them to index the array.

  5. Print the array elements along with their corresponding index values to make a table showing how many times each letter occurred in the input.

  6. When you are done with your work don't forget to commit it to your branch:

              $ git commit -a -m "Some suitable message"

Submit your modified version of filters.adb to Moodle.

Last Revised: 2015-01-27
© Copyright 2015 by Peter C. Chapin <>