Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- class dodgyCharacters{
- public static void main(String [] args){
- try{
- Scanner taxpayer = new Scanner(new File("taxpayers.txt"));
- Scanner unemployed = new Scanner(new File("unemployed.txt"));
- ArrayList<String> tax = new ArrayList<String>();
- ArrayList<String> noJob = new ArrayList<String>();
- ArrayList<String> dodgy = new ArrayList<String>();
- String taxes = " ";
- while(taxpayer.hasNextLine()){
- String s = taxpayer.next();
- tax.add(s);
- }
- while(unemployed.hasNext()){
- String s = unemployed.next();
- noJob.add(s);
- }
- for(int k = 0; k < tax.size(); k++) {
- for(int l = 0; l < noJob.size(); l++){
- if(tax.get(k).equals(noJob.get(l))){
- dodgy.add(tax.get(k));
- }
- }
- }
- System.out.println(dodgy + " ");
- taxpayer.close();
- unemployed.close();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment