Answer to Question #255871 in Java | JSP | JSF for THE WOLVERINE

Question #255871
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 • the user can not enter numbers into their user name in user login otherwise it would return an error • where the user must enter atleast one cap character in the text field if not it returns an error • the user cannot enter special characters in the user name otherwise it would return an error.
1
Expert's answer
2021-10-24T18:50:03-0400
import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
 Scanner input = new Scanner(System.in);
 System.out.println("Enter name:\n");
 String S = input.nextLine();
 char[] string = S.toCharArray();
 StringBuilder builder = new StringBuilder();
 for(char c : string){
 if(Character.isDigit(c){
 System.out.println("Digits not allowed");
 builder.append(c);}}
 }
 }

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