part 1 of slot machine Slot Machine (Subfunctions and Branching) Part 5 The doub
ID: 3601721 • Letter: P
Question
part 1 of slot machine
Slot Machine (Subfunctions and Branching) Part 5 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 (0). Write a function IsThreeABs to detect from symbols of three windows (w1,w2,w3), if in all three windows there are either single bar, double bar or triple bar Function name: IsThreeABs 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 function AssignNumber, similar to what was specified in Slotmachine Part 1. Your function can simply call the function AssignNumber For example out = logical out = logical 1 Your Function Save C Reset MATLAB Documentation 1 function out-IsThreeABs (w1, w2, w3) % Your code goes here % 4 5 end 6 8 % Function will have access to following custom functions: AssignNumber Code to call your function C ResetExplanation / Answer
function out=IsThreeABs(w1, w2, w3)
out1 = AssignNumber(w1);
out2 = AssignNumber(w2);
out3 = AssignNumber(w3);
out = ((out1 <= 4 && out1 >= 2) || out1 == 6) && ((out2 <= 4 && out2 >= 2) || out2 == 6) && ((out3 <= 4 && out3 >= 2) || out3 == 6);
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.