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
Sample Output1:
Sample Input2:
5
Sample Output2:
Sample Input2:
5
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"); } } }