Question: make it better so that my second phrase outputs this Second phrase: Be cool Encoded text: Tj opiu not like what mine is

make it better so that my second phrase outputs this
Second phrase: "Be cool"
Encoded text: "Tj opiu"
not like what mine is outputting
Second phrase: "Be cool"
Encoded text: "Gq dixd"
void VigenereForwardIterator::encodeCurrentChar() noexcept {
if (fKeys != fKeys.end()){
if (fIndex >= fSource.length()){
fCurrentChar ='\0';
return;
}
char messageChar = fSource[fIndex];
if (std::isalpha(messageChar)){
char keywordChar =*fKeys;
if (!std::isalpha(keywordChar)||!std::isupper(keywordChar)){
fCurrentChar = messageChar;
return;
}
size_t row = keywordChar -'A';
size_t column = std::toupper(messageChar)-'A';
if (column < CHARACTERS){
char encodedChar = fMappingTable[row][column];
if (std::islower(messageChar)){
encodedChar = std::tolower(encodedChar);
}
fCurrentChar = encodedChar;
++fKeys;
if (fKeys == fKeys.end()){
fKeys = fKeys.begin();
}
}
else {
fCurrentChar = messageChar;
}
}
else {
fCurrentChar = messageChar;
}
}
}
void VigenereForwardIterator::decodeCurrentChar() noexcept {
if (fKeys != fKeys.end()){
if (fIndex >= fSource.length()){
fCurrentChar ='\0';
return;
}
char messageChar = fSource[fIndex];
if (std::isalpha(messageChar)){
char keywordChar =*fKeys;
if (!std::isalpha(keywordChar)||!std::isupper(keywordChar)){
fCurrentChar = messageChar;
return;
}
size_t row = keywordChar -'A';
size_t column =0;
while (column < CHARACTERS && fMappingTable[row][column]!= std::toupper(messageChar)){
++column;
}
if (column < CHARACTERS){
char decodedChar ='A'+ column;
if (std::islower(messageChar)){
decodedChar = std::tolower(decodedChar);
}
fCurrentChar = decodedChar;
++fKeys;
if (fKeys == fKeys.end()){
fKeys = fKeys.begin();
}
}
else {
fCurrentChar = messageChar;
}
}
else {
fCurrentChar = messageChar;
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!