+ 1

Password Validator

Can someone help me with this password validation code. It must contain at least 2 uppercase, 3 lowercase & 1 digit........ https://code.sololearn.com/cefU63K5cxFJ/?ref=app

8th Sep 2019, 8:13 PM
Jacques Cozart
Jacques Cozart - avatar
5 Answers
+ 3
import java.util.Scanner; public class password { public static void main(String[] args) { String pssWrd; char ch; int upprLtr =0; int lwrLtr=0; int numBr=0; int specChr=0; Scanner input = new Scanner(System.in); System.out.println("Enter New Password: "); System.out.println("Must Contain 2 Uppercase, 3 Lowercase, & 1 Digit: "); pssWrd = input.nextLine(); for(int i = 0; i < pssWrd.length(); i++) { ch = pssWrd.charAt(i); if(ch=='0'||ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5'||ch=='6'||ch=='7'||ch=='8'||ch=='9') { numBr = numBr+1; } if(Character.isUpperCase(ch)) { upprLtr++; } if(Character.isLowerCase(ch)) { lwrLtr++; } if(ch == '!' || ch== '@' || ch=='#' || ch=='
#x27; || ch=='%'||ch=='^' || ch=='&'||ch=='*'||ch=='_' || ch=='-' ) { specChr++; } } if(numBr<1){ System.out.println("Invalid amount of numbers"); } else if(upprLtr <2){ System.out.println("Invalid amount of Uppercase Characters"); } else if(lwrLtr<3){ System.out.println("Invalid amount of Lowercase Characters"); } else if(specChr<1){ System.out.println("Invalid amount of special Character"); } else{ System.out.println("Password is Valid"); } } } I have written the working code for password validator. Here is a suggestion for you. If you want to learn how to code efficiently, then you should learn how to work first hard. You have to put more efforts than this. The code you have uploaded is full of syntax errors, at least you can search on the internet for correct syntax, instead of just uploading code here and expecting someone will send you correct code. By this, you won't learn anything.
8th Sep 2019, 9:11 PM
Vijay Meena
+ 3
import re password= input() x = True while x: if (len(password)<7 or len(password)>999): break elif not re.search("[a-z]",password): break elif not re.search("[0-9]",password): break elif not re.search("[!@#$%&*]",password): break else: print("Strong") x=False break if x: print("Weak")
2nd Aug 2020, 3:04 PM
Ace Coder
Ace Coder - avatar
+ 1
use: int upprLtr=2;
5th May 2020, 12:44 AM
Amrish Kumar
Amrish Kumar - avatar
0
.......thx for the input.....
8th Sep 2019, 10:05 PM
Jacques Cozart
Jacques Cozart - avatar
11th Sep 2019, 11:19 AM
Shakti Singh
Shakti Singh - avatar