Question: Given a String variable email, write code using split method to print email id and domain in separate lines. Example: email -> info@yahoo.com Print: Email

Given a String variable email, write code using split method to print email id and domain in separate lines.

Example:

email -> info@yahoo.com

Print:

Email id: info

Email domain: yahoo.com

If email contains no @ character or multiple @ characters then print invalid email:

email -> hello-yahoo.com

print:

invalid email

email -> my@fancy@email.com

print:

invalid email

----------------------------------------

import java.util.*;

class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String email = input.nextLine(); //Write your code below } }

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!