From 7e9a39a3dbd1e45a522f6a74d118edf6a092cb36 Mon Sep 17 00:00:00 2001 From: konradkelly Date: Wed, 9 Apr 2025 11:10:11 -0700 Subject: [PATCH 1/3] created 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..721f6cd 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 f6db85b2dff730a87aec669df78d82eed52af8db Mon Sep 17 00:00:00 2001 From: konradkelly Date: Wed, 9 Apr 2025 11:24:39 -0700 Subject: [PATCH 2/3] added user input for password --- src/PasswordApp.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 721f6cd..278a799 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,10 +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 2f0f5c6300e690042f743a66032274d438af37f2 Mon Sep 17 00:00:00 2001 From: konradkelly Date: Wed, 9 Apr 2025 11:51:44 -0700 Subject: [PATCH 3/3] support for multiple passwords --- src/PasswordApp.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 278a799..37db940 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -5,6 +5,9 @@ public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Welcome to the password checker!"); + while (scan.hasNextLine()) { + + String password = scan.nextLine(); System.out.println("The password is: " + password); @@ -14,5 +17,18 @@ public static void main(String[] args) { } 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