From 5aca77f7a7204eebd5a39c034f8f9642a5a570ba Mon Sep 17 00:00:00 2001 From: vand <vand@dtu.dk> Date: Thu, 10 Jun 2021 19:35:08 +0000 Subject: [PATCH] Upload New File --- module5_multiplication_game.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 module5_multiplication_game.m diff --git a/module5_multiplication_game.m b/module5_multiplication_game.m new file mode 100644 index 0000000..721e3df --- /dev/null +++ b/module5_multiplication_game.m @@ -0,0 +1,17 @@ +disp('Welcome to multiplication game!') +disp('(Empty to quit)') + +s = 'start'; +while numel(s)>0 + a = randi([0, 9]); + b = randi([0, 9]); + s = input([num2str(a),'*',num2str(b),'='],'s'); + p = str2num(s); + if isempty(p) && ~isempty(s) + disp("I don't understand that.") + elseif p == a*b + disp('Good job!') + else + disp('Oh, no, try again.') + end +end \ No newline at end of file -- GitLab