import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;

class FindCustomer {

	public static void main(String[] args) {
		
		Customer[] arr = null;
		Scanner io = null;

		try {
			io = new Scanner(new File("accounts.csv"));			
		} catch (FileNotFoundException e) {
			System.out.println("file not found");
			return;
		}


		io.useDelimiter(",|\n");
		int numRecords = io.nextInt();

		arr = new Customer[numRecords];
		for(int i = 0; i < numRecords; i++) {
			int accountNum = io.nextInt();
			String lName = io.next();
			String fName = io.next();
			double bal = io.nextDouble();

			Customer c = new Customer(fName,lName,accountNum,bal);
			arr[i] = c;
		}	
		io.close();

		printCustomers(arr);

		Scanner kb = new Scanner(System.in);

		System.out.println("Please enter customer details");
		int accountNum = kb.nextInt();
		String lName = kb.next();
		String fName = kb.next();
		double bal = kb.nextDouble();

		Customer d = new Customer(fName,lName,accountNum,bal);

		boolean found = false;
		for(Customer c : arr) {
			if (c.equals(d)) {
				found = true;
				break;
			}	
	
		}

		if (found) {
			System.out.println("Customer already exists");
		}
		else {
			System.out.println("Customer does not exist");
		}


	}

	public static void printCustomers(Customer[] arr) {
		for(Customer c : arr) {
			System.out.println(c.toString());
		}
	}

}
