Problem 1: The Basics [20pt] You get a summer job as a software engineer. Your b
ID: 3739366 • Letter: P
Question
Problem 1: The Basics [20pt] You get a summer job as a software engineer. Your boss wants you to work on a project to create software for playing card games software but work on only pieces of it. He calls you into his office and hands you a piece of paper showing the pseudocode of what he wants you to deo: online. He does not want you to complete the whole Goal is to create a program which asks a single user how many cards he/she wants and then displays the cards to the screen in a specific format Pseudocode: 1. ask a user how many cards he/she wants 2. initialize a deck of cards (52 cards, not shuffled) 3. shuffle the deck of cards 4. give the user his/her cards S. display the cards to the screen He warns that the whole code should only consist of I program and 6 functions. He you with a description of what the functions MUST input and MUST output (function input not keyboard input). He also warns that the cards must look like the ones shown. provides
Explanation / Answer
MATLAB PROGRAM:
Code for init deck
function y = init_deck()
f1='suit';
f2='name';
f3='val';
k=1;
for i=1:4
for j=1:13
switch i
case 1
val1='heart';
case 2
val1='spade';
case 3
val1='diamond';
case 4
val1='Club';
end
switch j
case 1
val2='A';
case 11
val2='J';
case 12
val2='Q';
case 13
val2='K';
end
s(k)=struct(f1,val1,f2,val2,f3,j);
k=k+1;
end
end
end
code for shuffle deck
function d = shuffle_deck(order)
i=1:52;
new=randomize_order();
d(new)=order(i);
end
code for randomize order
function n = randomize_order()
n=randperm(52,52);
end