Now modify the program so that it will count several different characters,
not just blank spaces. To keep things relatively simple we'll count the a's,
e's, s's, and t's (both upper and lower case) in the string. You need to declare
and initialize four additional counting variables (e.g. countA and so on).
Your current if could be modified to cascade but another solution is
to use a switch statement. Replace the current if with a
switch that accounts for the 9 cases we want to count (upper and lower case a, e,
s, t, and blank spaces). The cases will be based on the value of the ch
variable. The switch starts as follows -- complete it.
switch (ch)
{
case 'a':
case 'A': countA++;
break;
case ....
}
Note that this switch uses the "fall through" feature of switch statements. If
ch is an 'a' the first case matches and the switch continues execution
until it encounters the break hence the countA variable would be
incremented.