Respuesta :
We have that the print code is mathematically given as
The
for(int i=0; i<SIZE;i++){
if(possibles[i])cout<<words[i]<<" *CAN* be texted\n";
else cout<<words[i]<<" *CANNOT* be texted\n";
}
return 0;
}
Code
Generally the Code is
// to accurately convert from the letter to the key pad digit
int getLetterDigit(char letter){
switch(letter){
case 'a':case 'b': case 'c':return 2;
case 'd':case 'e': case 'f':return 3;
case 'g':case 'h': case 'i':return 4;
case 'j':case 'k': case 'l':return 5;
case 'm':case 'n': case 'o':return 6;
case 'p':case 'q': case 'r': case 's': return 7;
case 't':case 'u': case 'v':return 8;
case 'w':case 'x': case 'y': case 'z': return 9;
}
return 0;
}
// the digit is in the array - broken
bool isDigitInArray(int digit, int broken[], int size){
for(int i=0; i<size; i++){
if(broken[i]==digit)return true;
}
return false;
}
bool canBeTexted(string word, int broken[], int arraySize){
char letter; int digit;
for(int i=0; i<word.length(); i++){
letter = tolower(word.at(i));
digit = getLetterDigit(letter);
if(isDigitInArray(digit,broken,arraySize))
{
return false;
}
}
return true;
}
int main(){
const int SIZE = 11; //the size of the message there are 11 words
// the array
string words[SIZE] ={"Hi","John","I","am","sick","I","can\'t","come","to","play","today"};
bool possibles[SIZE];
int broken[] = {5,1}
for(int i=0; i<SIZE;i++){
possibles[i] = canBeTexted(words[i],broken,2);
}
// print the words that can be messaged and the one that cannot be
for(int i=0; i<SIZE;i++){
if(possibles[i])cout<<words[i]<<" *CAN* be texted\n";
else cout<<words[i]<<" *CANNOT* be texted\n";
}
return 0;
}
For more information on code visit
https://brainly.com/question/950632