Loading problems/LabThree_ChapterEight.h 0 → 100644 +59 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 10/9/24. // // CHAPTER 8 /** * Reads in the contents of a file, and return the (case-insensitive) * English-letter frequencies within the file. * @param filename The name of the file to read. * @return A new array (allocated on the *heap*) whose i-th entry contains * the number of times the i-th letter of the English alphabet appears * within the file, either as a capital or lower-case letter. * * @example * If the file "example.txt" contains the following text: * The quick brown fox jumped over the lazy dog. * * Then labThree_pZero("example.txt") will return a 26-integer * array with, among others, the following values: * - Its 0th entry will be 1 - because the letter 'a' appears just once in the file. * - Its 3rd entry will be 2 - there are two 'd' 's in the file. * - It's 14th entry will be 4 - there are four 'o' 's in the file */ int *labThree_pZero(string filename); /** * @param filenameCSV A file in CSV (comma-separated values) format, * in which each table row is a line of fields, separated by commas, * following these rules: * - Fields may be enclosed in double quotes, or not. * - Fields *must* be enclosed in quotes if they contain a comma or * double-quote mark. * - Double-quotation marks inside quoted fields are doubled. * @return The maximum number of fields in any line of the file. * * @example 1 * Suppose the file "example.csv" contains the following, single line: * 1729, San Francisco, "Hello, World", "He asked: ""Quo vadis?""" * * Then labThree_pOne("example.csv") should return 4, corresponding to the * four fields: * - 1729 * - San Francisco * - Hello, World * - He asked: ""Quo vadis?"" * * @example 2 * Supples the file "example2.csv" contains the following lines: * a,b,c * "a", "b", "c", "d" * 1, 2 * * Then labThree_pOne(example2.csv") should return 4, corresponding to the * line with the most fields ("a", "b", "c", "d"). */ int labThree_pOne(string filenameCSV); // CHAPTER 9 problems/LabThree_ChapterNine.h 0 → 100644 +33 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 10/9/24. // // Chapter 9 /** * This class represents a student, with the following elements: * - A student has a name (string) and quiz score(s) (int). * - A student can be constructed with a name, or with a name and a quiz score. * - A student has an appropriate destructor. * - Quiz scores can be added, one at a time, to a student object with a method addQuizScore. * - A student has a method getAverageScore() that returns the average * of all scores entered for the student. * * @example * labThree_pTwo student("Jack Daniels"); * student.addQuizScore(100); * student.addQuizScore(70); * student.addQuizScore(70); * Then student.getAverageScore() should return 80, the average of 100, 70, and 70. */ class labThree_pTwo { // fill this in here. }; /** * This class */ class labThree_pThree { // fill this in here }; No newline at end of file Loading
problems/LabThree_ChapterEight.h 0 → 100644 +59 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 10/9/24. // // CHAPTER 8 /** * Reads in the contents of a file, and return the (case-insensitive) * English-letter frequencies within the file. * @param filename The name of the file to read. * @return A new array (allocated on the *heap*) whose i-th entry contains * the number of times the i-th letter of the English alphabet appears * within the file, either as a capital or lower-case letter. * * @example * If the file "example.txt" contains the following text: * The quick brown fox jumped over the lazy dog. * * Then labThree_pZero("example.txt") will return a 26-integer * array with, among others, the following values: * - Its 0th entry will be 1 - because the letter 'a' appears just once in the file. * - Its 3rd entry will be 2 - there are two 'd' 's in the file. * - It's 14th entry will be 4 - there are four 'o' 's in the file */ int *labThree_pZero(string filename); /** * @param filenameCSV A file in CSV (comma-separated values) format, * in which each table row is a line of fields, separated by commas, * following these rules: * - Fields may be enclosed in double quotes, or not. * - Fields *must* be enclosed in quotes if they contain a comma or * double-quote mark. * - Double-quotation marks inside quoted fields are doubled. * @return The maximum number of fields in any line of the file. * * @example 1 * Suppose the file "example.csv" contains the following, single line: * 1729, San Francisco, "Hello, World", "He asked: ""Quo vadis?""" * * Then labThree_pOne("example.csv") should return 4, corresponding to the * four fields: * - 1729 * - San Francisco * - Hello, World * - He asked: ""Quo vadis?"" * * @example 2 * Supples the file "example2.csv" contains the following lines: * a,b,c * "a", "b", "c", "d" * 1, 2 * * Then labThree_pOne(example2.csv") should return 4, corresponding to the * line with the most fields ("a", "b", "c", "d"). */ int labThree_pOne(string filenameCSV); // CHAPTER 9
problems/LabThree_ChapterNine.h 0 → 100644 +33 −0 Original line number Diff line number Diff line // // Created by Ari Trachtenberg on 10/9/24. // // Chapter 9 /** * This class represents a student, with the following elements: * - A student has a name (string) and quiz score(s) (int). * - A student can be constructed with a name, or with a name and a quiz score. * - A student has an appropriate destructor. * - Quiz scores can be added, one at a time, to a student object with a method addQuizScore. * - A student has a method getAverageScore() that returns the average * of all scores entered for the student. * * @example * labThree_pTwo student("Jack Daniels"); * student.addQuizScore(100); * student.addQuizScore(70); * student.addQuizScore(70); * Then student.getAverageScore() should return 80, the average of 100, 70, and 70. */ class labThree_pTwo { // fill this in here. }; /** * This class */ class labThree_pThree { // fill this in here }; No newline at end of file