フィルターのクリア

plz help me with this task

3 ビュー (過去 30 日間)
omar mahrous
omar mahrous 2021 年 7 月 28 日
コメント済み: Rik 2021 年 7 月 28 日
design a login .m_file allows only 3 trials for checking the username and password asn your login account in the HTI. The program stops after 3 trials only.
---> notes
you will need a comparing functions between what you write and the
correct username and password exist in your .m file
-------------------------------------------------------------------------
correct username : ---------------
correct passwerd : ---------------

回答 (1 件)

Chunru
Chunru 2021 年 7 月 28 日
correctpw = ["user1" "abcd12345";
"user2" "abcdefg"];
loginstatus = false;
while true
username = input('User Name: ', 's');
[tf, id] = ismember(username, correctpw(:,1));
if tf
break
else
printf('User does not exist\n');
end
end
for i=1:3
a = input('Login: ', 's');
if strcmp(a, correctpw(id, 2))
fprintf('Login successful.\n');
loginstatus = true;
break
else
fprintf('Login failed.\n');
end
end
if ~loginstatus
fprintf('You have faile to login 3 times.\n');
en
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
  1 件のコメント
Rik
Rik 2021 年 7 月 28 日
You should not provide full solutions to homework questions. You can find guidelines for posting homework on this forum here. For answering homework questions there aren't really guidelines, but that thread might give you some ideas.
I would personally suggest storing a counter in a persistent, so you can use functions.

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

カテゴリ

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