Here is my work: http://pastebin.com/embed_js.php?i=WtkvfxVY //** So what im try
ID: 3540330 • Letter: H
Question
Here is my work: http://pastebin.com/embed_js.php?i=WtkvfxVY
//** So what im trying have the user put in one of the domains last. When I start using domain 2 on the second part I get this as my output;
"Email Address OK
Invalid Email Address
Email Address OK
Invalid Email Address
Email Address OK
Invalid Email Address
Email Address OK "
//**So how can I fix this for the second and the rest of the domains. ANOTHER thing im also trying to figure out is have the @ before the domain. would I use .beginsWith?????? Thank you
char ampersand = '@';
String domain1 = ".com";
String domain2 = ".edu";
String domain3 = ".org";
String domain4 = ".mil";
String domain5 = ".gov";
String domain6 = ".net";
Boolean ending = input.endsWith(domain1);
if (ending == false ) {
System.out.println( "Invalid Email Address" );
}
else {
System.out.println( "Email Address OK " );
}
Boolean endin = input.endsWith(domain2);
if (endin == false ) {
System.out.println( "Invalid Email Address" );
}
else {
System.out.println( "Email Address OK " );
break;
}
Explanation / Answer
char ampersand = '@';
String domain1 = ".com";
String domain2 = ".edu";
String domain3 = ".org";
String domain4 = ".mil";
String domain5 = ".gov";
String domain6 = ".net";
Boolean ending = input.endsWith(domain1);
if (ending == true ) {
System.out.println( "Email Address OK" );
break;
}
Boolean endin = input.endsWith(domain2);
if (endin == true ) {
System.out.println( "Email Address OK" );
break;
}
else {
System.out.println( "Invalid Email Address " );
break;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.