Guest User

Untitled

a guest
Feb 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.HashSet;
  4. import java.util.Scanner;
  5.  
  6. public class Runner
  7. {
  8.     private static HashSet<String> names = new HashSet<String>();
  9.    
  10.     public static void main(String [] args)
  11.     {
  12.         Scanner tax = null;
  13.         Scanner unem = null;
  14.        
  15.         try
  16.         {
  17.             tax = new Scanner(new File("taxpayers.txt"));
  18.             unem = new Scanner( new File("unemployed.txt"));
  19.         }
  20.         catch(FileNotFoundException e)
  21.         {
  22.             System.out.println("Files not found!");
  23.             System.out.println(e.toString());
  24.             System.exit(1);
  25.         }
  26.        
  27.         while(tax.hasNextLine())
  28.         {
  29.             String taxed = tax.nextLine();
  30.             names.add(taxed);
  31.         }
  32.        
  33.         while(unem.hasNextLine())
  34.         {
  35.             String unemployed = unem.nextLine();
  36.             if(!names.add(unemployed))
  37.             {
  38.                 System.out.println("Name : " + unemployed + " occured in both taxpayers and unemployed.");
  39.             }
  40.         }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment