Advertisement
ValtyValt

Untitled

Aug 28th, 2022
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Review
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             /* use this space to write your own short program!
  10.             Here's what you learned:
  11.  
  12.             BOOL TYPE: bool variableName
  13.             COMPARISON OPERATORS: ==, <, >, <=, >=
  14.             LOGICAL OPERATORS: &&, ||, !
  15.  
  16.             Good luck! */
  17.  
  18.             Console.Write("Please enter your password: ");
  19.             string password = Console.ReadLine();
  20.  
  21.             int upcaseCount = 0;
  22.             int symbolCount = 0;
  23.  
  24.             for (int i = 0; i < password.Length; i++)
  25.             {
  26.                 if (char.IsUpper(password[i])) upcaseCount++;
  27.                 if (char.IsLetterOrDigit(password[i])) symbolCount++;
  28.             }
  29.             if (symbolCount > 0) Console.WriteLine("Password has symbols!");
  30.             else Console.WriteLine("Password has no symbols!");
  31.             if (upcaseCount > 0) Console.WriteLine("Password has uppercase!");
  32.             else Console.WriteLine("Password has no uppercase!");
  33.  
  34.             bool passwordValidification = ((symbolCount = 0) && (upcaseCount = 0)); // <<<[CS0019] Operator '&&' cannot be applied to operands of type 'int' and 'int'
  35.             if (passwordValidification = true) Console.WriteLine("Your password is valid");
  36.             else Console.WriteLine("Your password is invalid");
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.         }
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement