Clear Filters
Clear Filters

making a multiplication program.

2 views (last 30 days)
Siddhartha
Siddhartha on 9 Feb 2018
Commented: Siddhartha on 10 Feb 2018
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!

Accepted Answer

KSSV
KSSV on 9 Feb 2018
Read about rand, prompt and find.
  1 Comment
Siddhartha
Siddhartha on 10 Feb 2018
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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!