Question
Annual Rainfall Report Write a program that displays the name of each month in a yearand its rainfall amount, sorted in order of rainfall from highestto lowest. The program should use an array of structures, whereeach structure holds the name of a month and its rainfall amount.Use a constructor to set the month names. Make the program modularby calling on different functions to input the rainfall amounts, tosort the data, and to display the data. Annual Rainfall Report Write a program that displays the name of each month in a yearand its rainfall amount, sorted in order of rainfall from highestto lowest. The program should use an array of structures, whereeach structure holds the name of a month and its rainfall amount.Use a constructor to set the month names. Make the program modularby calling on different functions to input the rainfall amounts, tosort the data, and to display the data.
Explanation / Answer
#include using namespace std;struct rain_fall{const char * month;double rain;}rf[12];class annual_rpt{private:struct rain_fall rf[12];public:annual_rpt(){memset(rf,0,sizeof(rf));}annual_rpt(struct rain_fall *r){int i;for(i=0;i