Advertisement
Stan0033

Untitled

Jun 16th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace strong_number
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. string password = Console.ReadLine();
  10.  
  11. int NumsCount = 0;
  12. int NonLetters = 0;
  13. if (password.Length >= 6 & password.Length <= 10)
  14. {
  15.  
  16. }
  17. else
  18. {
  19. Console.WriteLine("Password must be between 6 and 10 characters");
  20. }
  21. char[] all = password.ToCharArray();
  22. for (int i = 0; i < all.Length; i++)
  23. {
  24. if (char.IsLetter(all[i])) { } else { NonLetters++; }
  25. if (char.IsDigit(all[i])) { NumsCount++; }
  26. }
  27. if (NonLetters > 1 & NumsCount == 0)
  28. {
  29. Console.WriteLine("Password must consist only of letters and digits");
  30. }
  31. if (NumsCount >= 2)
  32. {
  33. Console.WriteLine("Password is valid");
  34. }
  35. else
  36. {
  37. Console.WriteLine("Password must have at least 2 digits");
  38. }
  39. }
  40.  
  41. }
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement