Java program of Mail Domain

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

Main.java

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");
        }
        
    }
}

Recommended:-

  1. Array square
  2. Generate number using odd digits
  3. Alternate Number Difference
  4. Next Greatest number
  5. Mark Comparison
  6. Print the characters in descending order
  7. Vowels in a fishBowl
  8. Least offer
  9. Ascending and descending order
  10. Mail Domain
  11. Count repeating words
  12. Sentence – Convert to upper and lower
  13. Count consecutive repeating characters
  14. Zig zag Array
  15. Pass and Fail Count
  16. Search a Course
  17. Average and Grade Calculation
  18. String – Find and replace the character (first occurrence)
  19. Sort the first and second half of an array
  20. Retail Shop
  21. Palindrome
  22. Numerology
  23. InitCap
  24. Array Compatiblilty
  25. Sum of the maximum and the minimum element
  26. String Concatenation
  27. Find Average Age
  28. Login
  29.  

Leave a Comment

Your email address will not be published. Required fields are marked *

x