From b86e706d672de0f927e9968557ba6cd805646b59 Mon Sep 17 00:00:00 2001 From: Kiyum-06 Date: Wed, 9 Apr 2025 11:09:37 -0700 Subject: [PATCH 1/3] hardcoded password and printed it --- src/PasswordApp.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 86fb0b1..ce5e28a 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,5 +1,10 @@ public class PasswordApp { public static void main(String[] args) { System.out.println("Welcome to the password checker!"); + + String password = "hello123"; + + System.out.println("The password is: " + password); + } } \ No newline at end of file From d266820cbadcf13f62d24cf9d097a48043766538 Mon Sep 17 00:00:00 2001 From: Kiyum-06 Date: Wed, 9 Apr 2025 11:23:57 -0700 Subject: [PATCH 2/3] user input for password --- src/PasswordApp.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index ce5e28a..f60a340 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,10 +1,20 @@ +import java.util.Scanner; + public class PasswordApp { public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Welcome to the password checker!"); - String password = "hello123"; + String password = scan.nextLine(); System.out.println("The password is: " + password); + if (password.length() >= 12) { + System.out.println("Your password is a good length"); + } else { + System.out.println("Your password is too short"); + } + } } \ No newline at end of file From cc37fffae973bc98c5acdbd972781f691912e49e Mon Sep 17 00:00:00 2001 From: Kiyum-06 Date: Wed, 9 Apr 2025 11:56:15 -0700 Subject: [PATCH 3/3] Support for multiple passwords --- src/PasswordApp.java | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index f60a340..d0e6cbb 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -6,15 +6,34 @@ public static void main(String[] args) { System.out.println("Welcome to the password checker!"); - String password = scan.nextLine(); + while(scan.hasNextLine()) { - System.out.println("The password is: " + password); + String password = scan.nextLine(); - if (password.length() >= 12) { - System.out.println("Your password is a good length"); - } else { - System.out.println("Your password is too short"); + System.out.println("The password is: " + password); + + if (password.length() >= 12) { + System.out.println("Your password is a good length"); + } else { + System.out.println("Your password is too short"); + } + + char[] characters = password.toCharArray(); + + boolean hasSpecial = false; + + for (int i = 0; i < characters.length; i++) { + char character = characters[i]; + if(Character.isAlphabetic(character) == false){ + hasSpecial = true; + } + } + + System.out.println("Has a special character: " + hasSpecial); + } + + } } \ No newline at end of file