I am writing a program for a class and I am having a problem that seems very simple yet I can't place my finger on it. I have to decode a message and everything decodes right except what is already there and should be showing up in the output which is things such as quotations and dashes.
the input file and sample output can be seen here
any help be great
http://www.cs.niu.edu/~abyrnes/csci240/pgms/240pgm6.htm
#include <iostream>
#include <iomanip>
using namespace std;
char convUpper ( char );
char convLower ( char );
char convPunct ( char );
char convDigit ( char );
char checkSpecial ( char );
int main()
{
char ch;
cin >> ch;
while (cin)
{
if ( isupper(ch) )
ch = convUpper(ch);
else if ( islower(ch) )
ch = convLower(ch);
else if ( ispunct(ch) )
ch = convPunct(ch);
else if ( isdigit(ch) )
ch = convDigit(ch);
else
ch = checkSpecial(ch);
//cout << ch;
cin >> ch;
//cout << ch;
}
system ("pause");
return 0;
}
/***************************************************************/
char convUpper ( char ch )
{
if (ch == 'A')
return ('z');
else
return (ch + 31);
}
/***************************************************************/
char convLower ( char ch )
{
if (ch == 'a')
return ('Z');
else
return (ch - 33);
}
/***************************************************************/
char convPunct ( char ch )
{
switch ( ch )
{
case '!':
return '0';
break;
case '@':
return '1';
break;
case ')':
return '2';
break;
case '(':
return '3';
break;
case '*':
return '4';
break;
case '%':
return '5';
break;
case '&':
return '6';
break;
case '$':
return '7';
break;
case '^':
return '8';
break;
case '#':
return '9';
break;
}
}
/***************************************************************/
char convDigit ( char ch )
{
switch (ch)
{
case '0':
return ',';
break;
case '1':
return '.';
break;
case '2':
return '$';
break;
case '3':
return '&';
break;
case '4':
return '%';
break;
case '5':
return '*';
break;
case '6':
return '(';
break;
case '7':
return ')';
break;
case '8':
return '?';
break;
case '9':
return '!';
break;
}
}
/***************************************************************/
char checkSpecial ( char ch )
{
if ( (int) ch == 30 )
return (32);
if ( (int) ch == 31 )
return ('\n');
}