フィルターのクリア

Make a quiz in matlab

51 ビュー (過去 30 日間)
Eddy Iswardi
Eddy Iswardi 2020 年 6 月 6 日
コメント済み: relamanma 2020 年 10 月 7 日
I have questions for my quiz like this example
questions = {'How many earth? '
'Is 7 a prime number? '
'How much water in glass? ' }
How to add the answer key?, my answer key is
How many earth = one
Is 7 a prime number = yes
How much water in glass = Not identify
the answer key is used to give a correction for the answer.
Example : when I answer 'no' for 'Is 7 a prime number?', the statement 'incorrect' will apper under the answer, but if I answer 'yes', the statement will be 'correct'

採用された回答

KSSV
KSSV 2020 年 6 月 6 日
questions = {'How many earth? '
'Is 7 a prime number? '
'How much water in glass? ' } ;
answers = {'one' , 'yes', 'Not identify'} ;
N = length(questions) ;
prompt = 'Answer: ' ;
for i = 1:N
fprintf(questions{i},'%s') ;
user_answer = input(prompt, 's') ;
if strcmpi(answers{i},user_answer) % compare answer
fprintf("Correct\n",'%s')
else
fprintf("Incorrect\n",'%s')
end
end
  3 件のコメント
KSSV
KSSV 2020 年 6 月 6 日
Funny.....majority of the questions here are homeworks......
relamanma
relamanma 2020 年 10 月 7 日
thx

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by