Write a program which helps a pupil to learn 9×9 multiplication table. The program imposes random questions, for instance, “5 * 3 = ”, “2 * 6 = ”, “3 * 8 = ” etc. and the user should enter an answer. If the answer is not correct the program should display an error message and provide a right answer. The program has 5 different levels of difficulties which correspond to a number of seconds the use has to enter an answer. If the user does not manage to answer within the limited time, the program generates an error message.
-This is to make the table :
N = randi(12)
for i = 0:length(N);
fi(i)=9*N(i);
end
% With out loop
N = 1:10 ;
fi = 9*N ;
-The diffrent messages:
msgbox('Right answer')
errodlg('Right answer is.....',Error')
I have problem to make random Q, make pepole write the answer and get if that rigt or wrong and make the program 5 diffrent level.

 採用された回答

darova
darova 2020 年 4 月 11 日

0 投票

Here is start:
  • use input to ask the user to enter some number
  • use if..else..end statements to check if the answer is correct or not
  • msgbox as you mentioned above
  • pause(0.5) can be used to wait for the answer (0.5 seconds)

5 件のコメント

Ameer Hamza
Ameer Hamza 2020 年 4 月 11 日
How to exit the input() command after a specific number of seconds? pause() will not be helpful.
darova
darova 2020 年 4 月 14 日
i agree. Took me 3 days without success. How to resolve?
elo
elo 2020 年 4 月 14 日
Do can give mig a exempel på codes?? It is not work with mig
Ameer Hamza
Ameer Hamza 2020 年 4 月 14 日
darova, there is no good way to timeout on input() function. Some undocumented functions can be used to interrupt input(), but they also throw an error, and I couldn't figure out how to suppress the error message. The only way which makes sense to timeout on user input is to use inputdlg() with a timer as described here: https://www.mathworks.com/matlabcentral/answers/96229-how-can-i-have-a-dialog-box-or-user-prompt-with-a-time-out-period
darova
darova 2020 年 4 月 15 日
thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

elo
2020 年 4 月 11 日

コメント済み:

2020 年 4 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by