Filter löschen
Filter löschen

plz help me with this task

3 Ansichten (letzte 30 Tage)
omar mahrous
omar mahrous am 28 Jul. 2021
Kommentiert: Rik am 28 Jul. 2021
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 : ---------------

Antworten (1)

Chunru
Chunru am 28 Jul. 2021
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 Kommentar
Rik
Rik am 28 Jul. 2021
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by