Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/Write an application that accepts a user\'s password from an input dialog. //If

ID: 3652560 • Letter: #

Question

/Write an application that accepts a user's password from an input dialog.
//If the entered password is less than six characters, more than 10 characters, or does not contain at least one letter and one digit, prompt the user again.
// When the user's entry meets all the password requirements, prompt the user to reenter the password,
//and do not let the user continue until the second password matches the first one. Save the file as Password.java.

Explanation / Answer

// Alphonsus Delgra // November 23, 2010 // Lab 7-2 // Password // User inputs password that must meet requirements of // no less than six characters, no more than ten characters // and must contain at least one digit and one letter. // User then must re-enter password exactly in order to move on import javax.swing.*; public class Password { public static void main(String[] args) { String password = ""; String passwordRepeat = ""; char charBeingChecked; boolean letterPresent = false; boolean digitPressent = false; char charChecked; int len = password.length(); password = JOptionPane.showInputDialog("Enter your password: Must be 6 to 10 characters long Must contain at least one letter and one number"); while((len < 6 || len > 10) || !(password.isLetterorDigit(password))) { password = JOptionPane.showInputDialog("Invalid password Please re-enter password"); } if((len >= 6 || len