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:
-
Use paper for your design. Resist the urge to start writing code right away.
-
Figure out the structure of your program.
-
Figure out what variables you'll need.
-
First figure out what function(s) you will need and design the
function interface(s).
-
Create the program framework: headers, function declarations, main(),
variables, constants, function headers, empty function body and all
comments).
-
Fill out the comments in the body of your main and other functions.
-
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.
-
Compile and test your program. Add any errors found during these
phases to your checklist for next time.
Notes:
-
Read the lab carefully.
-
As always, this lab is due by 9am Friday.
-
Email the program and your updated code review checklist as text
attachments to rliston at ursinus dot edu.
NOTE: Name your files lab9_<your login name>.cpp and checklist_<your login name>.txt
Make sure the subject is the following: "CS 173 Lab 9 submission".
Richard Liston