From 7f002201eda98e90f47fe4992cfc74224c3215e9 Mon Sep 17 00:00:00 2001 From: Auberon Date: Wed, 9 Apr 2025 11:09:28 -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 9ff8a8886ea2e12bbdf609c39c24ea0431f63f07 Mon Sep 17 00:00:00 2001 From: Auberon Date: Wed, 9 Apr 2025 11:23:47 -0700 Subject: [PATCH 2/3] user input for password --- src/PasswordApp.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 63544cb..4d742da 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,9 +1,18 @@ +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 885c2c5987995a948be6179b2dcab481d7170c0d Mon Sep 17 00:00:00 2001 From: Auberon Date: Wed, 9 Apr 2025 11:50:59 -0700 Subject: [PATCH 3/3] support for multiple passowrds --- src/PasswordApp.java | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 4d742da..1bc363a 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -5,14 +5,29 @@ public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Welcome to the password checker!"); - String password = scan.nextLine(); + while(scan.hasNextLine()) { + String password = scan.nextLine(); - System.out.println("The password is: " + password); + 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"); + 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