Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- import static java.lang.System.*;
- public class DonorSort
- {
- public static void main(String args[]) throws IOException
- {
- Scanner file = new Scanner(new File("sample.txt"));
- int num = file.nextInt();
- file.nextLine();
- String line1 = file.nextLine();
- String line2 = file.nextLine();
- String temp = "";
- ArrayList<String> group1 = new ArrayList<String>();
- ArrayList<String> group2 = new ArrayList<String>();
- ArrayList<String> lastYear = new ArrayList<String>();
- ArrayList<String> bothYears = new ArrayList<String>();
- ArrayList<String> thisYear = new ArrayList<String>();
- // for(int s=0; s<
- for(int i=0; i<line1.length(); i++)
- {
- if(line1.charAt(i) == ',')
- {
- group1.add('"' + temp + '"');
- temp = "";
- continue;
- }else{
- temp = temp + line1.charAt(i);
- }
- }
- group1.add('"' + temp + '"');
- temp = "";
- for(int x=0; x<line2.length(); x++)
- {
- if(line2.charAt(x) == ',')
- {
- group2.add('"' + temp + '"');
- temp = "";
- continue;
- }else{
- temp = temp + line2.charAt(x);
- }
- }
- group2.add('"' + temp + '"');
- temp = "";
- System.out.println(group1);
- System.out.println(group2);
- for(int i=0; i < group1.size(); i++)
- {
- for(int x=0; x < group2.size(); x++)
- {
- if(group1.get(x).equals(group2.get(x)))
- {
- String holder = group1.get(x);
- bothYears.add(holder);
- }
- }
- }
- System.out.println(lastYear);
- System.out.println(bothYears);
- System.out.println(thisYear);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement