Question: Write a Mat lab function called swapcode. m that takes a string txt as input and returns another string swaptxt as output. The function encodes

Write a Mat lab function called swapcode. m that takes a string txt as input and returns another string swaptxt as output. The function encodes the string by reversing the alphabet: it replaces each 'a' with 'z', each 'b' with 'y', each 'c' with 'x', etc. The function must work for uppercase letters the same way, but it must not change any other characters. Note that if you call the function twice like this txtout = flipcode(flipcode(txtin)) then the string stored in txtout will be identical to the string stored in txtin. The specifications for the function and some sample function calls are shown below. input parameter txt a string output parameter swaptxt a string sample function calls swapcode('This is a sentence.') produces 'Gsrh rh z hvmgvmxv. ' swapcode('Who has a 3 - legged dog?') produces 'Dsl szh z 3-ovttvw wit?' swapcode(swapcode('Dave97')) produces 'Dave 97
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
