Question: Here is the C++ code . Please fill in the TODO comment with a valid C++ code. this is the expected output for the code

 Here is the C++ code . Please fill in the TODO comment with a valid C++ code. this is the expected output for the code . 
Total rainfall: 36.2 inches Month Average Rainfall (in) Jan...................0.030 Feb...................0.012 Mar...................0.095 Apr...................0.083 May...................0.146 Jun...................0.147 Jul...................0.236 Aug...................0.082 Sep...................0.130 Oct...................0.123 Nov...................0.077 Dec...................0.020 Month with greatest rainfall: Jul Month with least rainfall: Feb 

 #include  #include  #include  #include  #include  #include  const char* INPUT_FILE_NAME{"data.txt"}; const size_t NUM_MONTHS{12}; const size_t MAX_NUM_DAYS{31}; /* * The following acts as a sentinel value to fill in columns of data * to maintain a rectangular two-dimensional array. For example, for * months that have only 30 days, the rainfall for the 31st day (i.e., * column) is marked with a -1.0 in the input data file. Similarly for * February, in which there are only 29 days (the data file contains * data from 2016 which was a leap year), there are -1.0 values placed * in the 30th and 31st days (i.e., columns). */ const double INVALID_DATA{-1.0}; enum month_t{JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, UNKNOWN}; /** * Get data from the supplied data file. The supplied data file contains * precipitation data for Springfield in the year 2016. * @param data a two-dimensional array that gets initialized with data */ void getData(double data[][MAX_NUM_DAYS]); /** * A helper function that returns the enum following the given enum which * is used to facilitate for-loops iterating over month_t instances. * @param month a particular month enum * @return The month that follows the given month is returned, unless the * given month is DEC, in which UNKNOWN is returned. */ month_t getNext(month_t month); /** * Calculate the total rainfall stored in the given array. * @param data a two-dimensional array containing rainfall information * @return The total amount of rainfall for the year stored in the given * array is returned. */ double totalRainfall(double data[][MAX_NUM_DAYS]); /** * Calculate the average rainfall for a given month. * @param data a two-dimensional array containing rainfall information * @param month the month for which we wish to calculate average rainfall * @return The average rainfall for the given month is returned. */ double averageForMonth(double data[][MAX_NUM_DAYS], size_t month); /** * Determine the month with the most rainfall. * @param data a two-dimensional array containing rainfall information * @return The month that has the most rainfall is returned. */ month_t monthWithMostRainfall(double data[][MAX_NUM_DAYS]); /** * Determine the month with the least rainfall. * @param data a two-dimensional array containing rainfall information * @return The month that has the leasr rainfall is returned. */ month_t monthWithLeastRainfall(double data[][MAX_NUM_DAYS]); /** * A utility function that displays various statistics surrounding the * data maintained in the given two-dimensional array. * @param data a two-dimensional array containing rainfall information */ void displayStatistics(double data[][MAX_NUM_DAYS]); /** * @brief Entry point for this application. * * @return 0 is returned upon successful execution. */ int main() { double stats[NUM_MONTHS][MAX_NUM_DAYS]; getData(stats); displayStatistics(stats); return EXIT_SUCCESS; } // end program void getData(double data[][MAX_NUM_DAYS]) { std::ifstream input{INPUT_FILE_NAME}; if (input.is_open()) { for (month_t month{JAN}; month <= DEC; month = getNext(month)) { for (size_t day{0}; day < MAX_NUM_DAYS; ++day) { input >> data[month][day]; } } input.close(); } else { std::cout << "Unable to open input file" << std::endl; } } month_t getNext(month_t month) { switch(month) { case JAN: return FEB; case FEB: return MAR; case MAR: return APR; case APR: return MAY; case MAY: return JUN; case JUN: return JUL; case JUL: return AUG; case AUG: return SEP; case SEP: return OCT; case OCT: return NOV; case NOV: return DEC; case DEC: return UNKNOWN; default: return UNKNOWN; } } double totalRainfall(double data[][MAX_NUM_DAYS]) { // TODO: Implement me. Once implemented, commit your changes.  return 0; } double averageForMonth(double data[][MAX_NUM_DAYS], size_t month) { // TODO: Implement me. Once implemented, commit your changes.  return 0; } month_t monthWithMostRainfall(double data[][MAX_NUM_DAYS]) { // TODO: Implement me. Once implemented, commit your changes.  return JAN; } month_t monthWithLeastRainfall(double data[][MAX_NUM_DAYS]) { // TODO: Implement me. Once implemented, commit your changes.  return JAN; } void displayStatistics(double data[][MAX_NUM_DAYS]) { // TODO: Implement me. Once implemented, commit your changes.  

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!