0% found this document useful (0 votes)
14 views2 pages

Import Java

The document is a Java program that checks the conditions of a user-entered password. It verifies if the password contains uppercase letters, lowercase letters, alphabetic characters, digits, and meets a minimum length of 8 characters. The program outputs the results of these checks and indicates whether the password meets all requirements.

Uploaded by

gva
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Import Java

The document is a Java program that checks the conditions of a user-entered password. It verifies if the password contains uppercase letters, lowercase letters, alphabetic characters, digits, and meets a minimum length of 8 characters. The program outputs the results of these checks and indicates whether the password meets all requirements.

Uploaded by

gva
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class PasswordConditionChecker {

public static void main(String[] args) {


Scanner scanner = new Scanner([Link]);
[Link]("Enter your password: ");
String password = [Link]();

checkPasswordConditions(password);

[Link]();
}

public static void checkPasswordConditions(String password)


{
boolean hasUpper = false;
boolean hasLower = false;
boolean hasAlpha = false;
boolean hasDigit = false;
boolean hasMinLength = [Link]() >= 8;

for (char ch : [Link]()) {


if ([Link](ch)) hasUpper = true;
if ([Link](ch)) hasLower = true;
if ([Link](ch)) hasAlpha = true;
if ([Link](ch)) hasDigit = true;
}

[Link]("Password Check Results:");


[Link](hasUpper ? "✅ Contains uppercase
letter" : "❌ Must contain an uppercase letter");
[Link](hasLower ? "✅ Contains lowercase
letter" : "❌ Must contain a lowercase letter");
[Link](hasAlpha ? "✅ Contains alphabet
letter" : "❌ Must contain at least one alphabet letter");
[Link](hasDigit ? "✅ Contains number
(digit)" : "❌ Must contain at least one number");
[Link](hasMinLength ? "✅ Minimum length is 8
characters" : "❌ Password must be at least 8 characters long");

// Final pass/fail
if (hasUpper && hasLower && hasAlpha && hasDigit &&
hasMinLength) {
[Link]("\n✅ Password meets all
requirements.");
} else {
[Link]("\n❌ Password does NOT meet all
requirements.");
}
}
}

You might also like