+ 1
Password Validator program in Java, all conditions are not fulfilling in coach (getting error in 4 out of 13 cases). Pls assist.
Below is link to question amd my program. The program is running fine for my test cases but not able to find error/solve 4 test cases. Question/Coach link: https://www.sololearn.com/coach/76?ref=app My program Link: https://code.sololearn.com/c7goNGrQ5WFb/?ref=app Task: Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has at a minimum 2 numbers, 2 of the following special characters ('!', '@', '#', '
#x27;, '%', '&', '*'), and a length of at least 7 characters. If the password passes the check, output 'Strong', else output 'Weak'. Input Format: A string representing the password to evaluate. Output Format: A string that says 'Strong' if the input meets the requirements, or 'Weak', if not. Sample Input: Hello@$World19 Sample Output: Strong6 odpowiedzi
+ 2
the simpler code is better. I believe the problem is either with your switch statement or your classes, though its not clear to me extactly which it is. try using if else instead of the switch. if that still doesn’t work, place your codes directly in main. here is my code that works for ref
https://code.sololearn.com/cKy4yY05S2WE/?ref=app
+ 1
Hi, there are a few different issues with your code. First the section at line 16 is unnecessary. There is nothing in the problem that says certain characters are excluded.
Second, your counts are not considering that digits and special chars could be repeated.
ex: ghy44!!
the code coach challenge would consider that string Strong but your code would print Weak.
+ 1
though to be fair, there are some applications in the real world that do not allow repeating characters in passwords. 😉
+ 1
sorry Kapil I couldn’t determine the exact cause. It might be a code coach issue. when I ran your code with some minor changes the number of test case failures fluctated between 6 and 2 - even if I hadn’t made further changes.
0
I have initially tried the simpler form (no line 16 and duplication of special characters & number were allowed), but the code still didn't work for last 4 conditions.
I have again modified the code for reference.
Link:
https://code.sololearn.com/cDF2qqkuJ3X6/?ref=app
0
Thanks Elizabeth Kelly . Appreciate your efforts. Your code did work for all cases. I'll continue to look for the issues in my code.