Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.HashSet;
- import java.util.Scanner;
- public class Runner
- {
- private static HashSet<String> names = new HashSet<String>();
- public static void main(String [] args)
- {
- Scanner tax = null;
- Scanner unem = null;
- try
- {
- tax = new Scanner(new File("taxpayers.txt"));
- unem = new Scanner( new File("unemployed.txt"));
- }
- catch(FileNotFoundException e)
- {
- System.out.println("Files not found!");
- System.out.println(e.toString());
- System.exit(1);
- }
- while(tax.hasNextLine())
- {
- String taxed = tax.nextLine();
- names.add(taxed);
- }
- while(unem.hasNextLine())
- {
- String unemployed = unem.nextLine();
- if(!names.add(unemployed))
- {
- System.out.println("Name : " + unemployed + " occured in both taxpayers and unemployed.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment