making a multiplication program.

5 vues (au cours des 30 derniers jours)
Siddhartha
Siddhartha le 9 Fév 2018
Commenté : Siddhartha le 10 Fév 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!

Réponse acceptée

KSSV
KSSV le 9 Fév 2018
Read about rand, prompt and find.
  1 commentaire
Siddhartha
Siddhartha le 10 Fév 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by