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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by