From ca5976db21f409b112670c5512b50d7975e039a1 Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:09:42 -0700 Subject: [PATCH 1/3] hardcoded password and printed it --- src/PasswordApp.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 86fb0b1..63544cb 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,5 +1,9 @@ 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 a4a2ac5af999d7371b5aa9e3055277a6433d2169 Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:23:54 -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 63544cb..9531364 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,9 +1,19 @@ +import java.util.Scanner; + public class PasswordApp { public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + System.out.println("Welcome to the password checker!"); - String password = "hello123"; + String password = scanner.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 d9add76cf42bac1fd22774427981e4ced720a6d5 Mon Sep 17 00:00:00 2001 From: Gulyapas Poonkawinsiri <67386394+joetlobb@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:51:08 -0700 Subject: [PATCH 3/3] support for multiple passwords --- src/PasswordApp.java | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 9531364..065d9dd 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -6,14 +6,30 @@ public static void main(String[] args) { System.out.println("Welcome to the password checker!"); - String password = scanner.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"); + while (scanner.hasNextLine()) { + + String password = scanner.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"); + } + + 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