Question: 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

 Problem 3: [15 marks] Validate Email Address (filename: ValidateEmailAddr.java) a Design

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!