Switch is not replacing character as expected
I'm an old dog trying to teach myself C. I'm using C Primer Plus by Prada and reading the chapter on if, else, else if, switch, continue etc and the problem is asking to take the if else version of this program to be converted into a switch program. The if else program replaces the period and exclamation fine but the way I've written this program seems to just add the exclamations and not replace them. Can someone please clue me in as to where I'm going wrong with this thing? Thank you!
Code:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
const char EXCL = '!';
int main(int argc, const char **argv)
{
int ch;
int sub, sub1;
printf("Enter some text. '.' replaced with '!' and '!' replaced with '!!'.\n");
while((ch = getchar()) != '#')
{
if(ch == '\n')
continue;
putchar(ch);
if(ch)
{
switch(ch)
{
case '.':
putchar(EXCL);
sub++;
break;
case '!':
putchar(EXCL);
putchar(EXCL);
sub1++;
break;
default:
break;
} //switch
} //if
} //while
printf("\n%d .'z and %d !'z", sub, sub1);
return 0;
}