From a5abc72f44e365b048aa2044a4ba025a6acda44d Mon Sep 17 00:00:00 2001 From: kriseattle Date: Wed, 9 Apr 2025 11:09:44 -0700 Subject: [PATCH 1/3] I inserted line --- src/PasswordApp.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 86fb0b1..1497f34 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,5 +1,8 @@ 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 2ece5b84d887937a956e4350d7eeb7025947c9a9 Mon Sep 17 00:00:00 2001 From: kriseattle Date: Wed, 9 Apr 2025 11:23:58 -0700 Subject: [PATCH 2/3] I inserted user input --- src/PasswordApp.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 1497f34..f6f75bb 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,8 +1,17 @@ +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 7c4445a849fabb6fe3b34bf54a9eb60a66d5fba5 Mon Sep 17 00:00:00 2001 From: kriseattle Date: Wed, 9 Apr 2025 11:48:14 -0700 Subject: [PATCH 3/3] I insterted more code --- passwords | 3 +++ src/PasswordApp.java | 32 +++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 passwords diff --git a/passwords b/passwords new file mode 100644 index 0000000..b28064b --- /dev/null +++ b/passwords @@ -0,0 +1,3 @@ +hello +hello123 +hellothere12345 \ No newline at end of file diff --git a/src/PasswordApp.java b/src/PasswordApp.java index f6f75bb..54879bb 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -4,14 +4,32 @@ public class PasswordApp { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Welcome to the password checker!"); + System.out.println("Please enter the desired password"); - String password = scan.nextLine(); - System.out.println("The password is: " + password); + while (scan.hasNextLine()){ + 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!!!"); - } + if(password.length() >= 12){ + System.out.println("Your password is a good length!"); + } else { + System.out.println("Your password is too short!!!"); + } + + //make char array from user input + char[] characters = password.toCharArray(); + + boolean hasSpecialChar = false; + + for (int i = 0; i < characters.length; i++){ + char character = characters[i]; + if(Character.isAlphabetic(character) == false){ + hasSpecialChar = true; + } + } + + System.out.println("Password has a special character: " + hasSpecialChar); } + +} } \ No newline at end of file