From 5d759b29ebe6041e8a6b57397c609610d2c6a33c Mon Sep 17 00:00:00 2001 From: Brendan Villaraza Date: Wed, 9 Apr 2025 11:09:48 -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 7dbf6208b180bdc7f98ea2faf3a81de29f62d16c Mon Sep 17 00:00:00 2001 From: Brendan Villaraza Date: Wed, 9 Apr 2025 11:24:13 -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..b7cfd21 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 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("Yourpassword is a good length!"); + } else{ + System.out.println("Your password is to short"); + } } } \ No newline at end of file From cbe4b7cf2b34d031feed0eefa086c210b3e1c45d Mon Sep 17 00:00:00 2001 From: Brendan Villaraza Date: Wed, 9 Apr 2025 11:58:42 -0700 Subject: [PATCH 3/3] Finished the last part added passwords to check rather than input --- src/PasswordApp.java | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index b7cfd21..1ccff41 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -5,14 +5,30 @@ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Welcome to the password checker!"); - String password = scanner.nextLine(); + while (scanner.hasNextLine()) { + + - System.out.println("The password is: " + password); - - if (password.length() >= 12) { - System.out.println("Yourpassword is a good length!"); - } else{ - System.out.println("Your password is to short"); + String password = scanner.nextLine(); + + System.out.println("The password is: " + password); + + if (password.length() >= 12) { + System.out.println("Yourpassword is a good length!"); + } else{ + System.out.println("Your password is to short"); + } + char[] characters = password.toCharArray(); + + boolean hasSpecial = false; + + for(int i = 0; i < characters.length; i++){ + char character = characters[i]; + if(Character.isAlphabetic(character) == true){ + hasSpecial = true; + } + } + System.out.println("Has a special character " + hasSpecial); } } } \ No newline at end of file