Morse code translator

Problem solved. PM user for solution.
Last edited on
closed account (o1vk4iN6)
You don't capitalize the sentence again as it's on the outside of your loop that repeats for every input.

Also if you are going to use a switch statement with that many cases are least make it take up less room and make it easier to read...

1
2
3
4
5
6
7
switch (sentence[j]){
	case 'A': cout << ".- "; break;
	case 'B': cout << "-... "; break;
	case 'C': cout << "-.-. "; break;
	case 'D': cout << "-.. "; break;
	case 'E': cout << ". ";   break;
// ... 


You could probably use some kind of array instead of the switch statement.
Last edited on
You don't convert the second sentence to uppercase.
Yay, it works! Thank you for the help.

@xerzi: I'll keep that in mind. I was following the convention used in the C++ tutorial. I was actually going to try programming the Morse code translator with an array as my next attempt.
Last edited on
Topic archived. No new replies allowed.