23.23.1: Slot machine (Branching) Part 7 All sevens or all double This tool is p
ID: 3607395 • Letter: 2
Question
23.23.1: Slot machine (Branching) Part 7 All sevens or all double This tool is provided by a third party. Your activity is always LAB ACTIVITY diamonds? recorded, but you may need to refresh the page to fill in the banner Slot machine Part 7 The double diamond slot machine game has three windows. Each window shows either a double diamond (DD), a cherry (C'), a single bar (B'), double bar ('BB) or triple bar ('BBB), or the number seven (7) or a blank (O'. Complete the test function with subfunctions to detect from symbols of three windows (w1,w2,w3), if all three windows have sevens or all double diamonds. The double diamond is wild and can represent a sever subfunction name: lls3Sevens Inputs: w1,w2,w3 (type: string); Output: logical subfunction name: Is3Diamonds Inputs: w1,w2,w3 (type: string); Output: logical Hint: In writing branching code, instead of using the symbols, use the corresponding numbers Restriction: The function must use the custom functions AssignNumber and NumberofDoubleDiamonds written in Slotmachine Part 1 and Part 2, respectively. Your function can simply call the function AssignNumber and NumberofDoubleDiamonds For example output2] = TestTheSevensAndDiamonds(w1,w2 ,w3) >>[output 1, output! Logical output2 logicalExplanation / Answer
function out=AssignNumber(W)
switch(W)
case "DD"
out = 6;
case "7"
out = 5;
case "BBB"
out = 4;
case "BB"
out = 3;
case "B"
out = 2;
case "C"
out = 1;
case "0"
out = 0;
otherwise
out = -1;
end
end
function out=NumberOfDoubleDiamonds(w1, w2, w3)
out1 = AssignNumber(w1);
out2 = AssignNumber(w2);
out3 = AssignNumber(w3);
out = 0;
if out1 == 6
out = out + 1;
end
if out2 == 6
out = out + 1;
end
if out3 == 6
out = out + 1;
end
end
function out=NumberOfSevens(w1, w2, w3)
out1 = AssignNumber(w1);
out2 = AssignNumber(w2);
out3 = AssignNumber(w3);
out = 0;
if out1 == 6 || out1 == 5
out = out + 1;
end
if out2 == 6 || out2 == 5
out = out + 1;
end
if out3 == 6 || out3 == 5
out = out + 1;
end
end
function out = Is3Sevens(w1, w2, w3)
if (NumberOfSevens(w1, w2, w3) == 3)
out = true;
else
out = false;
end
end
function out=Is3Diamonds(w1, w2, w3)
if (NumberOfDoubleDiamonds(w1, w2, w3) == 3)
out = true;
else
out = false;
end
end
function [test1, test2] = TestTheSevensAndDiamonds(w1, w2, w3)
test1 = Is3Sevens(w1, w2, w3);
test2 = Is3Diamonds(w1, w2, w3);
end
On console
w1='DD'; w2 = '7'; w3 = 'DD';
[output1, output2] = TestTheSevensAndDiamonds(w1, w2, w3)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.