Error In Password Checker

Link to project:
https://www.codecademy.com/courses/learn-c-sharp/projects/csharp-password-checker
.
Code:

using System; namespace PasswordChecker { class Program { public static void Main(string[] args) { int min_length = 8; string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string lowercase = uppercase.ToLower(); string digits = "123456789"; string special_chars = "`~!@#$%^&*()_{}[]|\'\"<>?/-+=;:\\.,"; Console.Write("Enter a password: "); string password = Console.ReadLine(); int score = 0; if (password.Length >= min_length) { score++; } if (Tools.Contains(password, uppercase)) { score++; } if (Tools.Contains(password, lowercase)) { score++; } if (Tools.Contains(password, digits)) { score++; } if (Tools.Contains(password, special_chars)) { score++; } if ((password == "password") || (password == "1234")) { score = 0; } switch (score) { case 4 || 5: Console.WriteLine("Your password is extremely strong in security."); break; case 3: Console.WriteLine("Your password is strong in security."); break; case 2: Console.WriteLine("Your password is medium in security."); break; case 1: Console.WriteLine("Your password is weak in security."); break; default: Console.WriteLine("Your password doesn't meet any of the standards."); break; } } } }

.
How do I fix the error?

The error (when you run it in the CC lesson) is pretty descriptive. The point of a switch block is to check one value per case statement. That means, that this:

 case 4 || 5:

is not only redundant, but also wrong. As well, as the error message helpfully points out:

Operator '||' cannot be applied to operands of type 'int' and 'int'

You can’t use the || (or) operator between two int (integer) types.

3 Likes