Solution to The tap code, sometimes called the knock code, is a way to encode text messages … - Sikademy
Author Image

Archangel Macsika

The tap code, sometimes called the knock code, is a way to encode text messages on a letter-by-letter basis in a very simple way. Tap code has been one of the most basic communication protocols and still used to convey SOS messages and other urgent communication. The tap code uses a 5×5 grid of letters representing all the English alphabets, see Figure 1. To communicate the word "water", the cipher would be the following (with the pause between each number in a pair being shorter (single space) than the pause between letters (two spaces)), A B C/K D E F G H I J L M N O P Q R S T U V W X Y Z Your task is to design a program that can i) convert any given string into a Tap code sequence Prototype: char* convertToTapCode(char*) ii) and A Tap code sequence to a string (char*) Prototype: char* convertToString(char*) Note: 1) only use following library : #includeNote: however, you can use char* helping link

The Answer to the Question
is below this banner.

Can't find a solution anywhere?


Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

using namespace std; //Tap Codes string StrToUpper(string s) { int n; for(n=0;n<s.length();n++) { if(s[n]>='a' && s[n]<='z') s[n] = s[n]-32; } return(s); } void convertToTapCode(string s) { char Letters[5][5]= { {'A','B','C','D','E'}, {'F','G','H','I','J'}, {'L','M','N','O','P'}, {'Q','R','S','T','U'}, {'V','W','X','Y','Z'} }; int r,c,n; s = StrToUpper(s); cout<<"\nTap Code for "<<s<<" = "; for(n=0;n<s.length();n++) { for(r=0;r<5;r++) { for(c=0;c<5;c++) { if(s[n]=='K') s[n]= 'C'; if(s[n]==Letters[r][c]) cout<<"("<<r+1<<", "<<c+1<<"), "; } } } } char convertToString(int x, int y) { char Letters[5][5]= { {'A','B','C','D','E'}, {'F','G','H','I','J'}, {'L','M','N','O','P'}, {'Q','R','S','T','U'}, {'V','W','X','Y','Z'} }; return(Letters[x-1][y-1]); } int main() { string s = "Water"; convertToTapCode(s); return(0); }

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1096-qpid-92