hi, I'm a first-level java learner, so my questions might seem really basic. but I don't really have a clue as to what I'm doing wrong. Can you guys please help out?
I'm supposed to write a program that ask the user to input their email address. and The first letter and the last letter cannot be '@'. Moreover, '@' is supposed to be included somewhere in the middle of the input.
I'm asking the user to input the data in PersonDB class. and I'm trying to write the validator for the email in another class called the Validator.
so in the PersonDB class, I have:
System.out.println("Enter Email Address: ");
String email = sc.next();
int strLength = email.length();
System.out.println("" + strLength);
c.setEmail(email);
and in the Validator class, I have:
boolean validateEmail(String emailValid)
{
isvalid = false;
while (emailValid[0] =='@' || emailValid[emailValid - 1] == '@')
{
System.out.println("ERROR! you cannot enter @ at the beginning or the end of your email address.\n");
}
if (emailValid[0] != '@' && emailValid[strLength - 1] != '@')
{
if (int index = 0, index < strLength, index++)
{
//don't know what to do here
}
}
return isvalid;
}
I know this is not right. But I don't have a clue as to what I should do.