#need help adding error code to my program when inserting the wrong string

13 messages · Page 1 of 1 (latest)

uneven spindleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

drifting saffron
#

You're doing basically nothing that's in that assignment

#

It asks you to write a program that translates a single character, not a string. And it says you should use a switch statement to translate the letters, not some ascii values math.

versed narwhal
versed narwhal
# versed narwhal #include <iostream> using namespace std; int main() { char ch; cout << ...

cout << "ROT13 Caesar Cipher for " << ch << " - > ";
switch (ch) {
case 'A':
cout << 'N' << endl;
break;
case 'B':
cout << 'O' << endl;
break;
case 'C':
cout << 'P' << endl;
break;
case 'D':
cout << 'Q' << endl;
break;
case 'E':
cout << 'R' << endl;
break;
case 'F':
cout << 'S' << endl;
break;
case 'G':
cout << 'T' << endl;
break;
case 'H':
cout << 'U' << endl;
break;
case 'I':
cout << 'V' << endl;
break;
case 'J':
cout << 'W' << endl;
break;
case 'K':
cout << 'X' << endl;
break;
case 'L':
cout << 'Y' << endl;
break;
case 'M':
cout << 'Z' << endl;
break;
case 'N':
cout << 'A' << endl;
break;
case 'O':
cout << 'B' << endl;
break;
case 'P':
cout << 'C' << endl;
break;
case 'Q':
cout << 'D' << endl;
break;
case 'R':
cout << 'E' << endl;
break;
case 'S':
cout << 'F' << endl;
break;
case 'T':
cout << 'G' << endl;
break;
case 'U':
cout << 'H' << endl;
break;
case 'V':
cout << 'I' << endl;
break;
case 'W':
cout << 'J' << endl;
break;
case 'X':
cout << 'K' << endl;
break;
case 'Y':
cout << 'L' << endl;
break;
case 'Z':
cout << 'M' << endl;
break;
}
return 0;
}

versed narwhal
drifting saffron
#

Just use a default case to print the error

#

The assignment also said nothing about converting lowercase to uppercase, no idea why you're adding all these things

#
int main()
{
    char input, ouput;
    // request input char

    switch (input)
    {
    case 'A':
        output = 'N';
        break;
    // .. etc
    default:
        // print error message
        return 0;
    }

    // print conversion message
    return 0;
}
#

That should really be all you need to do

versed narwhal
#

Ohhh okay

uneven spindleBOT
#

@versed narwhal

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

versed narwhal
#

!solved