Home - kric/21 GitHub Wiki
-
clc
-
clear
-
y = 99;
-
n = 98;
-
cardmax =0;
-
disp('your goal is to get to or as close as you can to 21')
-
while cardmax <21
-
carddraw = input ('Do you want to draw a card? (y/n): ');
-
if carddraw == 99
-
Card = randi (10,1,1);
-
disp (Card)
-
cardmax = Card + cardmax;
-
elseif carddraw == 98
-
str = sprintf ('you have ended with a score of: ');
-
disp(str);
-
disp(cardmax);
-
cardmax = 99;
-
end
-
end
-
if cardmax> 21
-
disp ('You have lost')
-
end
-
if cardmax == 21
-
disp('you have won')
-
end