Mail Domain Program in java

Question:

ZeeZee Company provides an official id to its employees once they complete the pre-onboarding training. During the training, the zeezee company needs to send a mail to their personal ids. The company wants to send a mail to all the trainees. Help the company to find out the trainee’s personal mail id.

The employee’s official mail id will be [email protected] Find the mail domains apart from zeezee.com

[First input is the number of mail ids, the next inputs is the mail id]

Sample Input1:

5

[email protected]

[email protected]

[email protected]

[email protected]om

[email protected]

Sample Output1:

[email protected]

[email protected]

[email protected]

Sample Input2:

5

[email protected]

[email protected]

[email protected]

[email protected]

[email protected]

Sample Output2:

[email protected]

[email protected]

[email protected]

[email protected][email protected]

Sample Input2:

5

[email protected]

[email protected]

[email protected]

[email protected]

[email protected]

Sample Input2:

No personal mail id

CODE:

import java.util.*;
public class Main 
{
    public static void main (String[] args) {
        String test="zeezee.com";
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();//always give a blank nextLine if you are using string after int
        
        String email[][]=new String[n][2];
       
        for(int i=0;i<n;i++)
        {
            email[i]=sc.next().split("@");
        }
        
        int flag=0;
        for(int i=0;i<n;i++)
        {
            if((email[i][1]).equals(test))
            {
                flag++;
                continue;
            }
            else
            {
                System.out.println(email[i][0]+"@"+email[i][1]);
                
            }
        }
        if(flag==n)
        {
            System.out.println("No personal mail id");
        }
        
    }
}
Next:
  1. Count repeating words
  2. Sentence – Convert to upper and lower
  3. Count consecutive repeating characters

Leave a Comment

Scroll to Top