Package cs2110

Class Gradebook

java.lang.Object
cs2110.Gradebook

public class Gradebook extends Object
A collection of static methods for reading/writing gradebook tables in CSV format, transforming their data, and calculating summary statistics.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    static void
    Append "mean" and "standard deviation" columns to the end of the table `table`.
    static void
    Append "mean" and "standard deviation" rows to the bottom of the table `table`.
    static Seq<Seq<String>>
    Read contents of a csv file and use this to construct a nested row-major sequence of strings.
    private static <T> boolean
    isRectangular(Seq<Seq<T>> table)
    Return whether each element of `table` has the same size.
    static void
    main(String[] args)
    A basic application to add summary statistics to a gradebook spreadsheet table.
    static double
    mean(Seq<String> seq)
    Return the mean of the numerical entries of `seq`.
    static <T> void
    outputCSV(String filename, Seq<Seq<T>> table)
    Convert the contents of `table` into Simplified CSV format and write this to the file located at `filename`.
    static double
    powerSum(Seq<String> seq, int n)
    Return the sum of the n'th powers of all numerical entries of `seq`.
    static Seq<Seq<String>>
    roundEntries(Seq<Seq<String>> table, int decimalPlaces)
    Rounds all numerical data within `table` to the specified number of decimal places.
    static double
    Return the standard deviation of the numerical entries of `seq`.
    static <T> Seq<Seq<T>>
    transpose(Seq<Seq<T>> original)
    Return a new table that is the transpose of the original table.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • Gradebook Link icon

      public Gradebook()
  • Method Details Link icon

    • constructTable Link icon

      public static Seq<Seq<String>> constructTable(String filename) throws IOException
      Read contents of a csv file and use this to construct a nested row-major sequence of strings. Throws an IOException if `filename` cannot be accessed or read from.
      Throws:
      IOException
    • outputCSV Link icon

      public static <T> void outputCSV(String filename, Seq<Seq<T>> table) throws IOException
      Convert the contents of `table` into Simplified CSV format and write this to the file located at `filename`. Throws an IOException if `filename` cannot be accessed or written to.
      Throws:
      IOException
    • isRectangular Link icon

      private static <T> boolean isRectangular(Seq<Seq<T>> table)
      Return whether each element of `table` has the same size.
    • transpose Link icon

      public static <T> Seq<Seq<T>> transpose(Seq<Seq<T>> original)
      Return a new table that is the transpose of the original table. That is, the rows of the original table become the columns of the new table (and vice versa), and the orders of the entries in these rows / columns remains the same. Requires `original` is rectangular.
    • powerSum Link icon

      public static double powerSum(Seq<String> seq, int n)
      Return the sum of the n'th powers of all numerical entries of `seq`. A numerical entry is any entry that can be successfully parsed to a double by Double.parseDouble().
    • mean Link icon

      public static double mean(Seq<String> seq)
      Return the mean of the numerical entries of `seq`. Returns NaN (aka 0.0/0.0) if `seq` does not contain any numerical entries.
    • stdDev Link icon

      public static double stdDev(Seq<String> seq)
      Return the standard deviation of the numerical entries of `seq`. Returns NaN (aka 0.0/0.0) if `seq` does not contain any numerical entries.
    • addSummaryColumns Link icon

      public static void addSummaryColumns(Seq<Seq<String>> table)
      Append "mean" and "standard deviation" columns to the end of the table `table`. The first row of the table (the column "headers") has "mean" and "standard deviation" appended (in that order). In subsequent rows, the string representations of the mean and standard deviation (in that order) of the numerical entries are appended. All numbers are represented with full precision. Requires that `table` is rectangular with at least one row and that no rows alias one another.
    • addSummaryRows Link icon

      public static void addSummaryRows(Seq<Seq<String>> table)
      Append "mean" and "standard deviation" rows to the bottom of the table `table`. The first entries of these rows are "mean" and "standard deviation" (respectively). The subsequent entries are the mean and standard deviation (respectively) of the numerical entries in that column. All numbers are represented with full precision. Requires that `table` is rectangular with at least one column (implying at least one row).
    • roundEntries Link icon

      public static Seq<Seq<String>> roundEntries(Seq<Seq<String>> table, int decimalPlaces)
      Rounds all numerical data within `table` to the specified number of decimal places.
    • main Link icon

      public static void main(String[] args) throws IOException
      A basic application to add summary statistics to a gradebook spreadsheet table. Takes in two program arguments: the filepath of the input csv and the filepath for the output csv.
      Throws:
      IOException