// Complete this method so that it uses encryptedCharacter to
// return the encrypted version of theMessage using theOffset
return"Encryptred message";
if(theOffset>theMessage.length())// compares if the message is greater than theOffset.
{
theOffset=theOffset%theMessage.length();// it will constantly divide theOffset with the String in order to get a number that cannot be divided by theMessage.
}
elseif(theOffset<theMessage.length())// this selection statement compares if theOffset is less than the String theMessage
{
theOffset=(theOffset%theMessage.length())+theMessage.length();// it will also divide theOffset with theMessage with the String but it will add the String as well.
//The reason for adding the String is that, theOffset is less than theMessage and in order for the program to work, theMessage is added to theOffset to make it a fair number to be used in the program.
}
for(intw=0;w<theMessage.length();w++){// loops through the String
charmorse=(char)theMessage.length();// the String is passed to the char called morse
morse=(char)(morse+theOffset);// the char morse adds itself with theOffset
if(morse>'Z'){// if morse is less than the capital Z, it will shift the alphabet to the left.
morse=(char)(morse-26);// During the shifting process, it will minus 26 as it will shift to the left.
}
else
{
if(morse<'A'){// if morse is greater than capital A, it will shift the alphabet to the right.
morse=(char)(morse+26);// During the shifting process, it will add 26 as it will shift to the right.
}
}
morse=(char)theMessage.length();// the char morse get passed to the String.
}
returntheMessage;// it will return the String theMessage.