How to connect two displays?

2 views (last 30 days)
Minhao Wang
Minhao Wang on 25 Sep 2020
Commented: Minhao Wang on 25 Sep 2020
clc;clear
C1 = input('Please enter a code to break: ' , 's');
if length(C1) ~= 6
disp('Decoy message: Not a six-digit number.');
else
A = mod(sum(C1 - '0'),2);
end
if A == 1
disp('Decoy message: Sum is odd.')
else
C2 = (C1(1) - '0') * (C1(2) - '0') - (C1(3) - '0');
end
switch C2
case 1
disp('Rescue on Monday')
case 2
disp('Rescue on Tuesday')
case 3
disp('Rescue on Wednesday')
case 4
disp('Rescue on Thursday')
case 5
disp('Rescue on Friday')
case 6
disp('Rescue on Saturday')
case 7
disp('Rescue on Sunday')
otherwise
disp('Decoy message:Invalid rescue day.');
end
F1 = str2num(C1(4));
F2 = str2num(C1(5));
F3 = str2num(C1(6));
if mod(F1,3) == 0
B = F2 - F3;
else
B = F3 - F2;
end
switch(B)
case 1
disp('at the bridge.');
case 2
disp('at the library.');
case 3
disp('at the river crossing.');
case 4
disp('at the airport.');
case 5
disp('at the bus terminal.');
case 6
disp('at the hospital.');
case 7
disp('at the St. Petes Church.');
otherwise
disp('Decoy message:Invalid rendezvous point.');
end
If we run this Script and enter 510129,it will appear:
Please enter a code to break: 510129
Rescue on Friday
at the St. Petes Church.
But I would like to make it appear :
Please enter a code to break: 510129
Rescue on Friday at the St. Petes Church.
How do I do that?

Accepted Answer

KSSV
KSSV on 25 Sep 2020
Edited: KSSV on 25 Sep 2020
clc;clear
C1 = input('Please enter a code to break: ' , 's');
if length(C1) ~= 6
disp('Decoy message: Not a six-digit number.');
else
A = mod(sum(C1 - '0'),2);
end
if A == 1
disp('Decoy message: Sum is odd.')
else
C2 = (C1(1) - '0') * (C1(2) - '0') - (C1(3) - '0');
end
switch C2
case 1
str1 = 'Rescue on Monday' ;
case 2
str1 = 'Rescue on Tuesday' ;
case 3
str1 = 'Rescue on Wednesday' ;
case 4
str1 = 'Rescue on Thursday' ;
case 5
str1 = 'Rescue on Friday' ;
case 6
str1 = 'Rescue on Saturday' ;
case 7
str1 = 'Rescue on Sunday' ;
otherwise
str1 = 'Decoy message:Invalid rescue day.' ;
end
F1 = str2num(C1(4));
F2 = str2num(C1(5));
F3 = str2num(C1(6));
if mod(F1,3) == 0
B = F2 - F3;
else
B = F3 - F2;
end
switch(B)
case 1
str2 = ('at the bridge.');
case 2
str2 = ('at the library.');
case 3
str2 = ('at the river crossing.');
case 4
str2 = ('at the airport.');
case 5
str2 = ('at the bus terminal.');
case 6
str2 = ('at the hospital.');
case 7
str2 = ('at the St. Petes Church.');
otherwise
str2 = ('Decoy message:Invalid rendezvous point.');
end
str = [str1,' ', str2] ;
fprintf("%s\n",str) ;

More Answers (0)

Categories

Find more on Properties in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!