Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3: [15 marks] Validate Email Address (filename: ValidateEmailAddr.java) a Design an algorithm and then write a program that asks the user to enter an

image text in transcribed
Problem 3: [15 marks] Validate Email Address (filename: ValidateEmailAddr.java) a Design an algorithm and then write a program that asks the user to enter an email address, and checks and displays if the email address is valid. To be valid the email address must meet the following criteria 2 1) Must be of the form a@b.c with exactly one @ symbol and exactly one dot (period) appearing somewhere after the i) There must be at least one character before the @, at least one character between the and the dot, and at least one character after the dot. b. Before validating the email address, use s=s.trim() to remove any spaces the user might have added before or after it c. You will need to use the indexOf() and lastIndexO) functions to find the locations of the @symbol and the dot symbol. Given a string. 5, s.indexOf( @) will give you the leftmost index of the @ symbol. s.lastIndexOff'@) will give you the rightmost index. If the symbol is not present they will return-1. The functions will search for any parameter string you specify. So, if you know the first and last index of @', how can you tell if it only occurs once? d. Once you have confirmed that there is exactly one and exactly one dot, use their indices and the length of the string to confirm that the address is valid. For example, if the is the first character, the address is invalid You don't need to check if the other characters are letters

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

Students also viewed these Databases questions