Borrar filtros
Borrar filtros

making a multiplication program.

3 visualizaciones (últimos 30 días)
Siddhartha
Siddhartha el 9 de Feb. de 2018
Comentada: Siddhartha el 10 de Feb. de 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!

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by