-2

So I'm working on a project for school. I need to record the data from my arrays into Excel and I'm having some trouble. This is part of my experiment class.

public static void exp(Params params) {
        Scanner s = new Scanner(System.in);
        String temp;
        for (temp = ""; temp.isEmpty(); temp = s.nextLine()) {
            System.out.println("Enter a directory and filename that you want the results to be saved under.");
            System.out.println("(If no directory is specified, results will be in same folder as the jar.)");
        }

        params.setFileName(temp);
        s.close();
        System.out.println("Executing...");
        long timeArray[] = new long[params.getFinalSize() / params.getIncrement()];
        int counter = 0;
        SortFacade facade = new SortFacade();
        for (int n = params.getInitialSize(); n <= params.getFinalSize(); n += params.getIncrement()) {
            System.out.println((new StringBuilder("Array of size: ")).append(n).toString());
            long tempTime = 0L;
            for (int j = 0; j < params.getNumTrials(); j++) {
                System.out.println((new StringBuilder("Trial #")).append(j + 1).toString());
                params.generateArrays(n, params.getTypeList());
                tempTime += facade.sort(params);
            }

            timeArray[counter] = tempTime / (long) params.getNumTrials();
            counter++;
        }

        params.setTimeArray(timeArray);
        System.out.println("Times for each array size(ms): " + Arrays.toString(timeArray));
        System.out.println("Writing to File...");
        System.out.println("Complete.");
    }

}
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366

1 Answers1

0

Start with Filewriter
Make sure what you write is comma-delimeted and saved as a .csv
Also, take a look at this existing question.

Community
  • 1
  • 1
Ceelos
  • 1,116
  • 2
  • 14
  • 35