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

Form below I just need the code for the error handling I have the rest and am fi

ID: 3661086 • Letter: F

Question

Form below I just need the code for the error handling I have the rest and am finishing it now just dont know what to put for error hangling or checking. I need to make sure they filled in a correct number from so I'm guessing something like this: // processing--check for correct quantity if (numOfChars <1 || nunmOfChars > 15) { has CorrectNumOfChars = false; errorMessage += " It does not have a valid quantity. "; I just cant get it to work. The assignment says to do it for everything listed I just dont know how to do error checkign for a name or the other things. Enter if returning customer (must enter y or n) Enter user name (must fill in a name) Enter at least 1 product to order Enter quantity (must enter 1

Explanation / Answer

For every field check whether the field is entered or not

Here fieldName = username, street, etc...

1) if(fieldName == null || (fieldName != null && fieldName.trim() == "")

errorMsg = "0Please enter the field"

2) //Add for every field any extra checks are there

for username

if(userName.length() < 8)

   errorMsg = "Please enter username with minumum 8 characters

Let me know if you need any thing