Azzera filtri
Azzera filtri

plz help me with this task

3 visualizzazioni (ultimi 30 giorni)
omar mahrous
omar mahrous il 28 Lug 2021
Commentato: Rik il 28 Lug 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 : ---------------

Risposte (1)

Chunru
Chunru il 28 Lug 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 Commento
Rik
Rik il 28 Lug 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.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by