Validation of an email address.
A valid email address consists of an email prefix and an email domain, both in acceptable formats. The prefix appears to the left of the @ symbol. The domain appears to the right of the @ symbol. For example, in the address example@mail.com, "example" is the email prefix, and "mail.com" is the email domain. Basic validation of an address is carried out client-side before data is sent to be processed server-side.
Write a program that validates an email address.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Acceptable email prefix formats:
Acceptable email domain formats:
Enter your email address: abc-@mail.com
Email address is invalid.
Enter your email address: abc-d@mail.com
Email address is valid.
Enter your email address: abc..def@mail.com
Email address is invalid.
Enter your email address: abc.def@mail.com
Email address is valid.
Enter your email address: abc.def@mail.c@
Email address is invalid.
Enter your email address: abc.def@mail.cc
Email address is valid.
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter your email address: name@domain.com
Email address is valid.
Enter your email address: n!me@domain.com
Email address is invalid.
Enter your email address: namedomain
Email address is invalid.
Enter your email address: name-123@domain
Email address is valid.
Enter your email address: name--123@domain
Email address is invalid.
Enter your email address: name@dom
Email address is valid.
Enter your email address: name@do
Email address is invalid.
Enter your email address: name@domain-123.com
Email address is valid.
Check that you have: