When I run through the code is won't get past checking if there is a letter or digit. It just keeps asking for it, and not sure how to fix it. This is for a homework assignment.
Thank you for your time.
Thank you for your time.
import java.util.Scanner; public class Password { public static void main (String args[]) { Scanner inputDevice = new Scanner(System.in); String password; String password2; int length; char aChar; boolean success = false; boolean match = false; while (!success) { System.out.println("Please enter a password"); password = inputDevice.nextLine(); length = password.length(); aChar = password.charAt(length-1); if (length >5 && length <10) { if (Character.isDigit(aChar)) { if (Character.isLetter(aChar)) { System.out.println("This is a good password"); success = true; while (!match) { System.out.println("Please retype password to confirm"); password2 = inputDevice.nextLine(); if (password.equals(password2)) { System.out.println("Your password matches"); match = true; } else System.out.println("Your password did not match"); } }else System.out.println("Password must contain a letter."); }else System.out.println("Password must contain a number."); } else System.out.println("Password must be between 6 and 10 numbers and/or digits, and must contain 1 of each."); } } }