Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On ancient rotary telephones each letter of the alphabet (except Q and Z) was pa

ID: 3930338 • Letter: O

Question

On ancient rotary telephones each letter of the alphabet (except Q and Z) was paired with one of the dial-able numbers 2 through 9 according to the following table: The number 0 was used to contact the operator, and the number 1 was used to begin a long-distance call, so they were not paired with any letters. The * and # symbols were also reserved for special uses and were thus not paired with any letters. Using the letter-number pairings from the table, people and businesses were able to make their phone numbers easier to remember. For example, to call Wells Fargo bank, you can dial 1-800-T0-WELLS, or a local animal shelter might have the number (FUN) DOG-N-CAT. Your job here is to write a Matlab function called how2call.m which takes a string wacky representing a phone number (and which may contain only upper-case letters, numbers, spaces, parentheses, and hyphens) and does the following: strips off the leading 1 (if one Is present in wacky) bullet changes the upper-case letters to numbers according to the table above bullet removes all spaces, hyphens, and parentheses bullet returns the phone number boring in the format (XXX) XXX-XXXX (where there is a space between the area code in parentheses and the beginning of the first 3 digit grouping). The specifications for the function and some sample function calls are shown below.

Explanation / Answer

function [boring] = how2call(wacky)
l=size(wacky,2);
disp(l);
res(1:10)='0';
i=1;
for j=1:l
if wacky(j)=='A'|| wacky(j)=='B'|| wacky(j)=='C'
res(i)='2';
i=i+1;
end
if wacky(j)=='D'|| wacky(j)=='E'|| wacky(j)=='F'
res(i)='3';
i=i+1;
end
if wacky(j)=='G'|| wacky(j)=='H'|| wacky(j)=='I'
res(i)='4';
i=i+1;
end
if wacky(j)=='J'|| wacky(j)=='K'|| wacky(j)=='L'
res(i)='5';
i=i+1;
end
if wacky(j)=='M'|| wacky(j)=='N'|| wacky(j)=='O'
res(i)='6';
i=i+1;
end
if wacky(j)=='P'|| wacky(j)=='S'|| wacky(j)=='R'
res(i)='7';
i=i+1;
end
if wacky(j)=='V'|| wacky(j)=='T'|| wacky(j)=='U'
res(i)='8';
i=i+1;
end
if wacky(j)=='X'|| wacky(j)=='W'|| wacky(j)=='Y'
res(i)='9';
i=i+1;
end
if wacky(j)=='0' || wacky(j)=='2' || wacky(j)=='3' ||wacky(j)=='4' || wacky(j)=='5' ||wacky(j)=='6' || wacky(j)=='7' ||wacky(j)=='8' || wacky(j)=='9'
res(i)=wacky(j);
i=i+1;
end
if wacky(j)=='-' || wacky(j)=='1' || wacky(j)==' ' || wacky(j)=='Q' || wacky(j)=='Z'
end
  
end
disp(res);
temp1=res(1:3);
temp2=res(4:6);
temp3=res(7:10);
boring=['(' temp1 ') ' temp2 '-' temp3];

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote