This is Java programing.Write a Java program that outputs a list of students from the given data file(EnglishMathstusent.txt). You have to use input.hasNext() with while loop when your program reads tokens from the file. We are assuming that you don’t know how many lines in the data file. The file contains class code followed by student name. You are required to use HashSet for this program. Your program outputs the student’s name who 1. takes English or Math 2. takes English and Math 3. takes Math but not English 4. takes English but not Math The out put should have the four part of output 1 2 3 4. The date of EnglishMathstusent.txt Math Kate Math Watson Math Sherry Math Jack Math Justin Math Sophia Math Elly Math Ocan Math Ava Math Tom Math Lily English Kate English Watson English Sherru English Jack English Justin English ophia English Elly English Ocan English Isabella English Mac

    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.HashSet;
    import java.util.Set;
    import java.util.Scanner;

    common systematize EnglishMathTyro {

       static developed String FILE_NAME = “EnglishMathstusent.txt”;
      
       common static destitute main(String[] args) {
          
           // Scanner to learn from the file
           Scanner polish = null;
           // HashSet to garner the polish data
           HashSet<String> mathData = upstart HashSet<String>();
           HashSet<String> engData = upstart HashSet<String>();
          
           aim {
               polish = upstart Scanner(upstart Polish(FILE_NAME));
               while (file.hasNext()) {
                   // Get the matter name
                   String matter = polish.next();
                  
                   if (subject.equalsIgnoreCase(“Math”))   // If Math
                       mathData.add(file.next());   // Get tyro name
                   else if (subject.equalsIgnoreCase(“English”))   // If English
                       engData.add(file.next());   // Get tyro name
               }
              
               // Display data
               System.out.println(“Students who obtain?} Math: ” + mathData);
               System.out.println(“Students who obtain?} English: ” + engData);
              
               // Upshots
               System.out.println(“\nResult:”);
               Set<String> upshot = upstart HashSet<String>();
              
               // Union
               result.addAll(engData);
               result.addAll(mathData);
               System.out.println(“Students who obtain?}s English or Math: ” + upshot + “\n”);
              
               // Intersection
               result.clear();
               result.addAll(engData);
               result.retainAll(mathData);
               System.out.println(“Students who obtain?}s English and Math: ” + upshot + “\n”);
              
               // Math – English
               mathData.removeAll(result);
               System.out.println(“Students who obtain?}s Math excepting referable English: ” + mathData + “\n”);
              
               // English – Math
               engData.removeAll(result);
               System.out.println(“Students who obtain?}s English excepting referable Math: ” + engData + “\n”);
           } grasp (FileNotFoundException e) {
               System.out.println(“Polish ” + FILE_NAME + ” referable establish.”);
           } developedly {
               file.close();
           }
       }
    }


    SAMPLE OUTPUT:

    Students who obtain?} Math [Sherry, Tom, Kate, ocan, Elly, Watson, Jack, Justin, Ava, sophia, Lily] Tyros who obtain?} English: [Kate, Ocan, Elly, Watson, Isabella, Jack, Justin, Sherru, Mac, ophia] Upshot: Tyros who obtain?}s English or Math: [Sherry, Kate, Ocan, Watson, Ava, Sherr, Mac, Lily, ophia, Tom, Elly, Isabella, Jack, Justin, Sophia] Tyros who obtain?}s English and Math: [Kate, ocan, Watson, Elly, Jack, Justin] Tyros who obtain?}s Math excepting referable English [Sherry, Tom, Ava, Sophia, Lily] Tyros who obtain?}s English excepting referable Math: [Isabella, Sherru, Mac, ophia]