Question: Can I get this in JOptionpane, please import java.io.*; import java.util.*; class PasswordVerifier {//class check the validity of password private String password; public PasswordVerifier(String a){

Can I get this in JOptionpane, please

import java.io.*; import java.util.*;

class PasswordVerifier {//class check the validity of password private String password; public PasswordVerifier(String a){ password = a; } public boolean verify(){ boolean upper,lower,digit; upper = false; lower = false; digit = false; if (password.length() < 6)//check the length is valid return false; for (int i=0; i= 'a' && password.charAt(i) <= 'z')//{check that contain at least one uppercase and at least one lowercase letter. lower = true; if (password.charAt(i) >= 'A' && password.charAt(i) <= 'Z') upper = true; //{check that The password should have at least one digit.} if (password.charAt(i) >= '0' && password.charAt(i) <= '9') digit = true; }

if (upper && lower && digit) return true; else return false; } }

public class Main{ public static void main(String[] args){

Scanner sc = new Scanner(System.in); System.out.print("Enter password: "); String pass = sc.next();//Taking the password from user PasswordVerifier pv = new PasswordVerifier(pass);//passing the user input password to check it is valid or not if (pv.verify()) System.out.println("Valid password"); else System.out.println("Invalid password");

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!