plz help me with this task

1 visualización (últimos 30 días)
omar mahrous
omar mahrous el 28 de Jul. de 2021
Comentada: Rik el 28 de Jul. de 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 : ---------------

Respuestas (1)

Chunru
Chunru el 28 de Jul. de 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 comentario
Rik
Rik el 28 de Jul. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by