Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Identifying an email in a simple email program [duplicate]

Xzavier:

This question already has an answer here:

  • How can I check if a single character appears in a string? 12 answers

What my issue is with this Program is finding the @ symbol. For example, if the user inputs "[email protected]" the output would be "[email protected] is an email". If the user does not use the "@" symbol at all the output would be "useremail" is not an Email, just as an example. So my question how am I to tell the program no matter where the "@" symbol is in the input it should print "is an email". if the "@" is not present anywhere in the input then print "is not an email".


public class Emails
{
public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

// establish @
String emailAt = "@";


// User inputs email with an @ or wihtout an @
System.out.println( "Enter a word: " );
String word = scan.next( );

/* if @ is present in input program prints "is an email ", if not system prints "is not an email" /*
if ( word.equals( emailAt ) )
System.out.println( word + " is an email " );
else
System.out.println( word + " is not an email " );


}
}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Identifying an email in a simple email program [duplicate]

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×