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

I need help writing this program in JAVA, this is an introductory java course, s

ID: 3817748 • Letter: I

Question

I need help writing this program in JAVA, this is an introductory java course, so if possible, keep it as basic/simple as possible while still following the instructions. The output should look like the sample execution at the end of the problem.

Write a program which validates a user's password based on the following properties:

must be at least 13 characters long

must have at least 4 digits

must have at least 7 letters

must have at least 3 uppercase letters

must have at least 2 non-alphanumeric characters

Input Validation:

No input validation required. Assume you will have a one word password, but your job is to make sure it follows the correct formatting

Requirements:

You should use boolean methods for each of the validations above.

Each of the validations above should be in separate methods. (Think about how you could use boolean methods to do this).

You are NOT allowed to use regular expressions.

Your output should state the following:

If the password is valid simply say "The password is valid".

If the password is invalid, your program should tell the user ALL properties that are invalid.

Explanation / Answer

import java.util.*;

import java.lang.*;
import java.io.*;


class Ideone
{
   public static void main (String[] args) throws java.lang.Exception
   {
       // your code goes here
//String password = "HHEqee1243yb$_";  

Scanner scanner = new Scanner( System.in );

  
       vaidate_password(password);
   }
  
  
   public static void vaidate_password(String password){
       boolean is_error = false;
       if(!check_length(password)){
           System.out.println("Password must be 13 character long.");
           is_error = true;
       }
       if(!check_digit(password)){
           System.out.println("Password must have at least 4 digits.");
           is_error = true;
       }
      
       if(!check_letter(password)){
           System.out.println("Password must have at least 7 letters.");
           is_error = true;
       }
      
       if(!check_upper(password)){
           System.out.println("Password must have at least 3 uppercase letters.");
           is_error = true;
       }
      
       if(!check_special(password)){
           System.out.println("Password must have at least 2 non-alphanumeric characters.");
           is_error = true;
       }
       if(!is_error)
           System.out.println("The password is valid.");
      
   }
  
  
  
  
  
  
  
  
   public static boolean check_length(String password)
   {
      
       return (password.length() >= 13 )? true : false;
   }
  
   public static boolean check_digit(String password)
   {
       int digit_count = 0;
       for(int i=0; i<password.length(); i++){
           int ch_ascii = (int) password.charAt(i);
           if(ch_ascii >= 48 && ch_ascii <= 57)
               digit_count++;
       }
      
       if(digit_count >= 4)
           return true;
       else
           return false;
   }
  
   public static boolean check_letter(String password)
   {
       int letter_count = 0;
       for(int i=0; i<password.length(); i++){
           if(Character.isLetter(password.charAt(i)))
               letter_count++;
       }
      
       if(letter_count >= 7)
           return true;
       else
           return false;
   }
  
   public static boolean check_upper(String password)
   {
       int letter_count = 0;
       for(int i=0; i<password.length(); i++){
           if(Character.isUpperCase(password.charAt(i)))
               letter_count++;
       }
      
       if(letter_count >= 3)
           return true;
       else
           return false;
   }
  
   public static boolean check_special(String password)
   {

       int letter_count = 0;
       for(int i=0; i<password.length(); i++){
           if(!Character.isLetterOrDigit(password.charAt(i)))
               letter_count++;
       }
      
       if(letter_count >= 2)
           return true;
       else
           return false;
   }
  
  
}