Question

FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java....

FOR JAVA:

Summary: Write a program to assess password stringency.

  • The solution should be named Password.java.
  • Include these steps:
    • Write an application that provides the criteria for a strong password, and accepts a user's password from an input dialog box.
    • If the entered password is less than six characters, more than 10 characters, or does not contain at least one uppercase letter and one digit, prompt the user to enter 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.
  • Run your program until it works and the output looks nice.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import javax.swing.JOptionPane;

public class Passwordn {

   public static void main(String[] args) {
       String pwd1;
       pwd1 = JOptionPane.showInputDialog("Enter a password ");
       while (true) {
           if (validatePassword(pwd1)) {
               break;
           }
           pwd1 = JOptionPane.showInputDialog("Invalid password: Enter a password ");
       }
       while (true) {
           String p2 = JOptionPane.showInputDialog("confirm password ");
           if (p2.equals(pwd1)) {
               JOptionPane.showMessageDialog(null, "Sucess...!!!");
               break;
           } else {
               JOptionPane.showMessageDialog(null, "Incorrect passowrd. Should match with first password");
           }

       }


   }

   public static boolean validatePassword(String pwd1) {
       if (pwd1.length() < 6 || pwd1.length() > 10) {
           return false;
       }

       if (!checkForUpperCasae(pwd1))
           return false;
       if (!checkNumbers(pwd1))
           return false;
       return true;

   }

   // checks if password has checkForUpperCasae
   public static boolean checkForUpperCasae(String pwd) {
       int count = 0;
       for (int i = 0; i < pwd.length(); i++)
           if (Character.isLetter(pwd.charAt(i)) && Character.isUpperCase(pwd.charAt(i)))
               count++;
       return count >= 1;
   }

   public static boolean checkForLowerCasae(String pwd) {
       for (int i = 0; i < pwd.length(); i++)
           if (Character.isLetter(pwd.charAt(i)) && Character.isLowerCase(pwd.charAt(i)))
               return true;
       return false;
   }

   // checks if password contains digit
   public static boolean checkNumbers(String pwd) {
       int count = 0;
       for (int i = 0; i < pwd.length(); i++)
           if (Character.isDigit(pwd.charAt(i)))
               count++;
       return count >= 1;
   }

}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a Java program to reset a user's password. The password must consist of exactly six...

    Design a Java program to reset a user's password. The password must consist of exactly six characters, of which one must be a digit, one must be an uppercase letter, and one must be a lowercase letter. Tell the user if the password is correct or if incorrect tell them what is wrong with it. For example, you could say: "Not valid! the password must have 6 characters! Goodbye!" Can't contain loops. Using Boolean, String, Int, char

  • How do I format this into C++? This the prompt: Design a class named Password that...

    How do I format this into C++? This the prompt: Design a class named Password that stores a password in a c-string and has member functions to test if the password complies with certain requirements as follows: The password should be between 6 and 20 characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. The password should have at least one punctuation character. Define a...

  • Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user...

    Using Python INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...

  • FOR JAVA: Summary: Create a program that stores info on textbooks. The solution should be named...

    FOR JAVA: Summary: Create a program that stores info on textbooks. The solution should be named TextBookSort.java. Include these steps: Create a class titled TextBook that contains fields for the author, title, page count, ISBN, and price. This TextBook class will also provide setter and getter methods for all fields. Save this class in a file titled TextBook.java. Create a class titled TextBookSort with an array that holds 5 instances of the TextBook class, filled without prompting the user for...

  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • 4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lo...

    4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lowercase letter, uppercase letter, or digit from 0-9, and must contain 10 characters, how many possible passwords are there if no character can be used more than once? Express your answer as a factorial statement. Is 8 an example of permutations or combinations? b. 4: A certain computer program is accessed by entering a user-defined password. If the password a. can...

  • C++: Imagine you are developing a software package that requires users to enter their own passwords....

    C++: Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: -The password should be at least six characters long. You can set the maximum size and let the user know -The password should contain at least one uppercase and at least one lowercase letter. -The password should have at least one digit. Write a program that asks for a password into a c-string and...

  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • In C Write a function that asks for the user's first, middle, and last names. The...

    In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...

  • Design and implement a Java program (name it PasswordTest) that accepts a string from the user...

    Design and implement a Java program (name it PasswordTest) that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict A good password will be at least 8 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT