From a6746b0b6e5dc8e0c772566d0fe2a0adc681dc05 Mon Sep 17 00:00:00 2001 From: Iquer_Dough <206500499+DennysSaenz123@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:09:29 -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 78272afd9c8f59ae94964dd769824795b630bfd8 Mon Sep 17 00:00:00 2001 From: Iquer_Dough <206500499+DennysSaenz123@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:23:54 -0700 Subject: [PATCH 2/3] Added scanner util to add user input for password --- src/PasswordApp.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index 63544cb..b98203d 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -1,9 +1,20 @@ + +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("your password is a good length"); + } else { + System.err.println("Your password is too short"); + } } } \ No newline at end of file From e254275c3a2e111a30476808440241eb9f80964d Mon Sep 17 00:00:00 2001 From: Iquer_Dough <206500499+DennysSaenz123@users.noreply.github.com> Date: Wed, 9 Apr 2025 11:52:20 -0700 Subject: [PATCH 3/3] Complete assignment --- src/PasswordApp.java | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/PasswordApp.java b/src/PasswordApp.java index b98203d..137885e 100644 --- a/src/PasswordApp.java +++ b/src/PasswordApp.java @@ -7,14 +7,29 @@ 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); + String password = scanner.nextLine(); - if(password.length() >= 12){ - System.out.println("your password is a good length"); - } else { - System.err.println("Your password is too short"); + System.out.println("The password is: " + password); + + if(password.length() >= 12){ + System.out.println("your password is a good length"); + } else { + System.err.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 + } + } \ No newline at end of file