From ed0db2096da73d471338209ac14b8a0466ad6b0b Mon Sep 17 00:00:00 2001 From: ryanrmills Date: Wed, 9 Apr 2025 11:23:47 -0700 Subject: [PATCH 1/3] user input --- src/PasswordApp.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 86fb0b1..b84bc70 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,5 +1,21 @@ +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!"); + + System.out.print("Please enter your password: "); + + String password = scan.nextLine(); + + System.out.println("The password is: " + password); + + if (password.length() < 12){ + System.out.println("Password length is too short."); + } else { + System.out.println("Your password is a good length."); + } } } \ No newline at end of file From f170f07e132e546d7ccbffd50882574e71c285dc Mon Sep 17 00:00:00 2001 From: ryanrmills Date: Wed, 9 Apr 2025 11:40:38 -0700 Subject: [PATCH 2/3] added check complexity --- src/PasswordApp.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index b84bc70..9334b9b 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -17,5 +17,18 @@ public static void main(String[] args) { } else { System.out.println("Your password is a good length."); } + + 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 From 5311536656d6b9653ac30282e16e26164837217b Mon Sep 17 00:00:00 2001 From: ryanrmills Date: Wed, 9 Apr 2025 11:51:17 -0700 Subject: [PATCH 3/3] updated --- passwords | 3 +++ src/PasswordApp.java | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 passwords diff --git a/passwords b/passwords new file mode 100644 index 0000000..cbd2162 --- /dev/null +++ b/passwords @@ -0,0 +1,3 @@ +hello +hello123 +hello1234567890 \ No newline at end of file diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 9334b9b..513a1eb 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -6,29 +6,30 @@ public static void main(String[] args) { System.out.println("Welcome to the password checker!"); - System.out.print("Please enter your password: "); + while (scan.hasNextLine()){ - String password = scan.nextLine(); + 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("Password length is too short."); - } else { - System.out.println("Your password is a good length."); - } + if (password.length() < 12){ + System.out.println("Password length is too short."); + } else { + System.out.println("Your password is a good length."); + } - char[] characters = password.toCharArray(); + char[] characters = password.toCharArray(); - boolean hasSpecial = false; + boolean hasSpecial = false; - for (int i = 0; i < characters.length; i++){ - char character = characters[i]; - if (Character.isAlphabetic(character) == false){ - hasSpecial = true; + 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); + System.out.println("Has a special character: " + hasSpecial); + } } } \ No newline at end of file