making a multiplication program.

2 次查看(过去 30 天)
I just started with Matlab a few weeks ago and I have to write a code that generates ten sets of two random single digit numbers. Then a user has to write in the product of these two random numbers and I have to provide feedback on how many answers were correct out of the ten sets. I don't know where to start in terms of how to make the user interact with the function and how to generate the ten sets. I can figure out how to provide the feedback logically but the way of providing feedback and generating the sets is new to me.
Thanks!

采纳的回答

KSSV
KSSV 2018-2-9
Read about rand, prompt and find.
  1 个评论
Siddhartha
Siddhartha 2018-2-10
So I created the code that asks for the user input and provide feedback after each quesiton. My problem is After the answering the set, I have to provide a summary of how many answers were correct and ask if they'd like another set of problems. I am not sure how to do these two things?
Code:
a=randi(9,1,1)
b=randi(9,1,1)
a*b==value;
prompt= 'what is the product of a*b?';
x=input(prompt);
y=a*b;
if x==y
fprintf('your answer is correct\n')
elseif fprintf('your answer is incorrect\n')
end
c=randi(9,1,1)
d=randi(9,1,1)
prompt= 'what is the product of b*d?';
x=input(prompt);
y=c*d;
if x==y
fprintf('your answer is correct\n')
elseif fprintf('your answer is incorrect\n')
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by