+ 1

Is there anyone that knows the input of test case 10 & 11 of password validation challenge in Code Coach section

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. I am solving it with python... Kindly help me out.

18th Jan 2020, 1:35 PM
Akintobi Idris A.
Akintobi Idris A. - avatar
3 Respostas
+ 2
import java.util.*; class PasswordValidator { public static void main(final String[] args) { int is1 = 0; int is2 = 0; int is3 = 0; Scanner sc = new Scanner(System.in); String s = sc.nextLine(); char ch[] = s.toCharArray(); int n = s.length(); int nnum=0; int ns=0; for(int i=0;i<n;i++) { if(n<7) { is1 = 0; break; } else if(n>=7) { is1 = 1; } if(Character.isDigit(ch[i])) { nnum++; if(nnum>=2) { is2 = 1; } else { is2 = 0; } } if(ch[i]=='!' || ch[i]=='@' || ch[i]=='#' || ch[i]=='%' || ch[i]=='
#x27; || ch[i]=='&' || ch[i]=='*') { ns++; if(ns>=2) { is3 = 1; } else { is3 = 0; } } } if(is1==1 && is2==1 && is3==1) System.out.print("Strong"); else if(is1==0 || is2==0 || is3==0) System.out.print("Weak"); } }
8th Apr 2020, 1:18 PM
Arfi Hussain
Arfi Hussain - avatar
+ 1
Use search 🔎 in code section...
18th Jan 2020, 1:50 PM
Mihai Apostol
Mihai Apostol - avatar
- 1
They are hidden for everybody.
18th Jan 2020, 1:41 PM
Mihai Apostol
Mihai Apostol - avatar