using System; namespace ConsoleApp4 { class Program { static void Main(string[] args) { string Username; string Password; int Zero; int CapCharacters; int LowCharacters; int Digits; int Symbols; int PassLength; Console.WriteLine("Hello user, please follow these instructions to create your new account.\n"); Console.Write($"Please enter a username to go by: "); Username = Console.ReadLine(); do { Zero = 0; CapCharacters = 0; LowCharacters = 0; Digits = 0; Symbols = 0; Console.Write($"\nAlright {Username}, now please enter a password: "); Password = Console.ReadLine(); // Password rules: 6-12 chara, 1 cap, 1 low, 1 num, 1 sym. PassLength = Password.Length; Console.WriteLine(""); while (Zero < PassLength) { if (Password[Zero] >= 'a' && Password[Zero] <= 'z') { LowCharacters++; } else if (Password[Zero] >= 'A' && Password[Zero] <= 'Z') { CapCharacters++; } else if (Password[Zero] >= '0' && Password[Zero] <= '9') { Digits++; } else { Symbols++; } Zero++; } if (Password.Length < 6) { Console.WriteLine("Error: Your Password is too short."); } if (Password.Length > 12) { Console.WriteLine("Error: Your Password is too long."); } if (CapCharacters < 1) { Console.WriteLine("Error: Your Password needs to contain a capital letter."); } if (LowCharacters < 1) { Console.WriteLine("Error: Your Password needs to contain a lowercase letter."); } if (Digits < 1) { Console.WriteLine("Error: Your Password needs to contain a digit."); } if (Symbols < 1) { Console.WriteLine("Error: Your Password needs to contain a symbol."); } } while (Password.Length < 6 && Password.Length > 12 && CapCharacters < 1 && LowCharacters < 1 && Digits < 1 && Symbols < 1); Console.WriteLine(""); Console.WriteLine("Congradulations, your account is now set up!"); Console.WriteLine(""); } } }
while (Password.Length < 6 || Password.Length > 12 || CapCharacters < 1 || LowCharacters < 1 || Digits < 1 || Symbols < 1);
Quote:while (Password.Length < 6 && Password.Length > 12 && CapCharacters < 1 && LowCharacters < 1 && Digits < 1 && Symbols < 1);
while (Password.Length < 6 || Password.Length > 12 || CapCharacters || 1 || LowCharacters < 1 || Digits < 1 || Symbols < 1);
&&
AND
Password.Length
!(A || B) == !A && !B !(A && B) == !A || !B
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)