making a multiplication program.

조회 수: 1 (최근 30일)
Siddhartha
Siddhartha 2018년 2월 9일
댓글: Siddhartha 2018년 2월 10일
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에서 Historical Contests에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by