Answer to Question #255634 in Java | JSP | JSF for Logan

Question #255634
Write a general error handling class that has general functions that would take in a string, which the main pages would get as an input and those functions can search for specific things. For example: any sort of input from the user where we would expect them to make a mistake( like where they enter numbers into their name in user login) and where the user must enter atleast one cap character in the text field if not it returns an error.
1
Expert's answer
2021-10-24T00:40:14-0400
/******************************************************************************


                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.


*******************************************************************************/


public class Main
{
	public static void main(String[] args) {
		  String special_char = "~`!@#$%^&*()-_=+\\|[{]};:'\",<.>/?";
    char CC;
    boolean numP = false;
    boolean upper = false;
    boolean lower = false;
    boolean special = false;
    System.out.print("Enter a string: ");
    for (int i = 0; i < input.length(); i++) {
        CC = input.charAt(i);
        if (Character.isDigit(CC)) {
            numP = true;
        } else if (Character.isUpperCase(CC)) {
            upper = true;
        } else if (Character.isLowerCase(CC)) {
            lower = true;
        } else if (special_char.contains(String.valueOf(CC))) {
            special = true;
        }
        else{
            System.out.print("Invalid login");
        }
    }


    return
      numP && upper && lower && special;
}}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS