CS 173 Lab 9: Vowel Counting


Objectives:

This lab will give you practice with "for" loops, "switch" statements, and additional work with functions. NOTE: there's a task you've been performing over and over in your main() functions. Break this out into a useful function and copy and paste into all your programs. This is called "code reuse" and it will save you time.


Your Task:

For this lab you will write a program that will process a text file called "input.txt" and write to an output file called "vowels.out" the number of each kind of vowel found in the text file. The file you will read in will begin with an integer (N) followed by a colon. The integer indicates how many subsequent characters you will read from the file. If there less than N characters, stop processing the file. Each character that is a vowel will get counted whether it is uppercase or lowercase. After reading all the characters (or terminating the loop if there aren't N characters) your main function will invoke a function called PrintVowels that prints out the counts of the vowels in the following form:
A: <number of A>
E: <number of E>
I: <number of I>
O: <number of O>
U: <number of U>
PrintVowels will be a void function that takes five arguments --- the counts of each of the vowels.


Suggestions for how to proceed:

  1. Use paper for your design. Resist the urge to start writing code right away.
  2. Figure out the structure of your program.
  3. Figure out what variables you'll need.
  4. First figure out what function(s) you will need and design the function interface(s).
  5. Create the program framework: headers, function declarations, main(), variables, constants, function headers, empty function body and all comments).
  6. Fill out the comments in the body of your main and other functions.
  7. Fill out the entire program before compiling, then review your code using your previous code review checklist as a guide. As you find errors, add them to your checklist.
  8. Compile and test your program. Add any errors found during these phases to your checklist for next time.

Notes:
Richard Liston