Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[(JAVA, ECLIPSE), Please keep the program as short as possible] 17.2: Valid Email Address? Part 3 [(JAVA, ECLIPSE), Please keep the program as short as

[(JAVA, ECLIPSE), Please keep the program as short as possible]

17.2: Valid Email Address? Part 3

[(JAVA, ECLIPSE), Please keep the program as short as possible]

  • Let's write a program, in a file named Email3.java, to check an email address to see if it is valid.
  • For the purposes of this assignment, we will use three criteria to determine if an email address is valid:
    • The address must end with one of the following extensions: .com, .org or .edu
    • The address must not contain a space
    • The address must have an @ character contained somewhere in the String
  • You will write 3 methods and 3 Javadoc comments. Each method will check each of the above conditions.
  • Your first method signature should look like this:

public static boolean validExtension(String address) {

//method body will go here

}

  • The second method signature should look like this:

public static boolean containsSpace(String address) {

//method body will go here

}

  • The third method signature should look like this:

public static boolean containsAt(String address) {

//method body will go here

}

  • Hint: Do not alter the starter code, given below, in any way. Your job is only to add to it where indicated:

/** * @author Name

* section info */ import java.util.Scanner; public class Email3 { public static void main(String[] args) { String address; Scanner input = new Scanner(System.in); System.out.print("Enter your email address: "); address = input.nextLine(); if (!containsAt(address)) { // the method will return true or false so // we can check in an if statement System.out.println("Invalid email. Your email address must contain an @ symbol"); } else if (false) { // replace false with method call here System.out.println("Invalid email. Your email address cannot contain a space"); } else if (false) { // replace false with method call here System.out.println("Invalid email. Your email must contain a .com, .edu or .org extension"); } else { System.out.println("Your email address is valid."); } }

//Write JAVADOC comment here for validExtension

public static boolean validExtension(String address) { // write method body here return false; }

//Write JAVADOC comment here for containsSpace

public static boolean containsSpace(String address) { // write method body here return false; }

//Write JAVADOC comment here for containsAt

public static boolean containsAt(String address) { // write method body here return false; } }

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

Students also viewed these Databases questions