ADoyle4

dodgyCharacters.java

Apr 20th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. class dodgyCharacters{
  4.  
  5. public static void main(String [] args){
  6. try{
  7. Scanner taxpayer = new Scanner(new File("taxpayers.txt"));
  8. Scanner unemployed = new Scanner(new File("unemployed.txt"));
  9. ArrayList<String> tax = new ArrayList<String>();
  10. ArrayList<String> noJob = new ArrayList<String>();
  11. ArrayList<String> dodgy = new ArrayList<String>();
  12. String taxes = " ";
  13.  
  14. while(taxpayer.hasNextLine()){
  15. String s = taxpayer.next();
  16. tax.add(s);
  17.  
  18. }
  19. while(unemployed.hasNext()){
  20. String s = unemployed.next();
  21. noJob.add(s);
  22. }
  23.  
  24. for(int k = 0; k < tax.size(); k++) {
  25. for(int l = 0; l < noJob.size(); l++){
  26. if(tax.get(k).equals(noJob.get(l))){
  27. dodgy.add(tax.get(k));
  28. }
  29. }
  30. }
  31. System.out.println(dodgy + " ");
  32. taxpayer.close();
  33. unemployed.close();
  34. }
  35.  
  36.  
  37. catch(Exception e){
  38. e.printStackTrace();
  39. }
  40.  
  41.  
  42.  
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment