Mail Domain Program in java

In this post, we will learn Mail Domain Program in java Programming language.

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 employeename@zeezee.com. 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

suvi@gmail.com

vivek@zeezee.com

john@yahoo.com

prem@zeezee.com

johan@gmail.com

Sample Output1:

suvi@gmail.com

john@yahoo.com

johan@gmail.com

Sample Input2:

5

suvi@gmail.com

vivek@gmail.com

john@yahoo.com

prem@yahoo.com

johan@gmail.com

Sample Output2:

suvi@gmail.com

vivek@gmail.com

john@yahoo.com

prem@yahoo.comjohan@gmail.com

Sample Input2:

5

femina@zeezee.com

jaya@zeezee.com

sri@zeezee.com

banu@zeezee.com

vijila@zeezee.com

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