Question: code=input(Please enter a code to break :, 's'); %input the code RandomString=num2str(code); % Convert a number to a string Length=strlength(RandomString); if Length~=9 %Check if the
code=input("Please enter a code to break :", 's'); %input the code RandomString=num2str(code); % Convert a number to a string Length=strlength(RandomString); if Length~=9 %Check if the code has 9 digits. disp('Decoy Message: Not a nine-digit number') else DigitString=RandomString-'0'; Getsumofdigits = sum(DigitString); % Get the sum of the string Remainder1 =mod(Getsumofdigits,2); % Check if the sum is even if Remainder1~=0 disp('Decoy Message: Sum is odd'); else rescue_date=DigitString(1)*DigitString(3)-DigitString(5); switch(rescue_date) case 1 rescue_date='Monday'; case 2 rescue_date='Tuesday'; case 3 rescue_date='Wednesday'; case 4 rescue_date='Thursday'; case 5 rescue_date='Friday'; case 6 rescue_date='Saturday'; case 7 rescue_date='Sunday'; otherwise rescue_date='Not_exist'; end if strcmp(rescue_date,'Not_exist') disp('Decoy Message: Invalid rescue day'); else rendezvous_point_code=DigitString(2)*DigitString(4)-DigitString(6); Remainder2=mod(rendezvous_point_code,3); if Remainder2==0 rendezvous_point=DigitString(7)-DigitString(9); switch (rendezvous_point) case 1 rendezvous_point='bridge'; case 2 rendezvous_point='library'; case 3 rendezvous_point='river crossing'; case 4 rendezvous_point='airport'; case 5 rendezvous_point='bus terminal'; case 6 rendezvous_point='hospital'; case 7 rendezvous_point='St. Petes Church'; otherwise rendezvous_point='Not_exist'; end else rendezvous_point=DigitString(8)-DigitString(9); switch (rendezvous_point) case 1 rendezvous_point='bridge'; case 2 rendezvous_point='library'; case 3 rendezvous_point='river crossing'; case 4 rendezvous_point='airport'; case 5 rendezvous_point='bus terminal'; case 6 rendezvous_point='hospital'; case 7 rendezvous_point='St. Petes Church'; otherwise rendezvous_point='Not_exist'; end if strcmp(rendezvous_point,'Not_exist') disp('Decoy Message: Invalid rendezvous point'); else Result=['Rescue on',rescue_date, 'at',rendezvous_point ]; disp(Result) end end end end end
If the nine digits number I putin fit all the limits, then I can't get the result.
It didn't display the "Result" matrix.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
