Email example we did in class

Problem description

Consider the email address: news@cnn.com

An email address has three parts:

domain: com
server: cnn
username: news

Write code that prints the domain, server, and username for any email address. Your output should look the like output shown above. You may assume that the email address is valid.

Note: The problem states any email address. Programs always implement general solutions (i.e., your code should work for any input).

You may add a Scanner to the program and prompt the user to input an email address. Prompting for input makes this program more valuable, but the goal of this exercise is to solve problems with loops.

Testing

Verify that the program works correctly with the following email addresses.

news@cnn.com
bsmith@radford.edu
rtgordon6@vt.edu

Verify that the program does not work correctly with the following email addresses.

brad23@radford
sjones.com
radford.edu

Debug each test case to identify where the problem is. Fix the code to handle all three invalid email addresses above. The code should terminate normally and print output without crashing. Do not use System.exit(0).

Solution

Email.java