The Ontario weather service manages precipitation data for various…
Question Answered step-by-step The Ontario weather service manages precipitation data for various… The Ontario weather service manages precipitation data for various regions in the province. The weather data is stored in a file (partially shown below – there are 96 records in total) and a program is needed that will summarize the contents of the file in various ways.Your job is to write the program (create the necessary modules, functions, macro’s, logic, etc.) that will produce correct data summaries and formatted output similar to that shown in the provided sample output text file attached to this question. Your program should be able to accommodate varying data file sizes up to a maximum 250 records.You MUST use the following function to read the data file and you are not allowed to make any changes to the function. This means that you will have to create the correct data structures required by the function. File Reading Functionint importWeatherDataFile(FILE* fp, struct WeatherRecord* data, int max){ int recs = 0; if (fp != NULL) { while (recs < max && fscanf(fp, "%d,%d,%lf,%c,%d,%15[^n]n", &data[recs].date.year, &data[recs].date.month, &data[recs].precipAmt, &data[recs].unit, &data[recs].location.regionCode, data[recs].location.name) == 6) { recs++; } } return recs; } weatherdata.txt2021,12,45.2,c,30,Ottawa2021,3,743,m,40,Halton2021,4,32.9,c,30,Ottawa2021,7,8.2,c,20,Thunder Bay2021,12,133,m,20,Kenora2021,6,106,m,30,Renfrew2021,1,646,m,40,Simcoe2021,11,72.2,c,10,Chatham-Kent2021,10,257,m,20,Thunder Bay2021,12,54.8,c,10,Chatham-Kent2021,11,61.5,c,40,Simcoe2021,2,18.8,c,10,Chatham-Kent2021,11,47.6,c,20,Kenora2021,12,57.5,c,20,Thunder Bay2021,9,28.1,c,20,Thunder Bay2021,5,326,m,30,Ottawa2021,7,376,m,40,Simcoe2021,10,515,m,40,Halton2021,8,76.9,c,10,Chatham-Kent2021,12,635,m,40,Simcoe2021,7,350,m,10,Chatham-Kent2021,9,48.9,c,30,Ottawa2021,11,13.5,c,20,Thunder Bay2021,6,143,m,20,Kenora2021,4,614,m,20,Kenora2021,3,299,m,20,Thunder Bay2021,9,672,m,40,Halton2021,7,71.7,c,40,Halton2021,8,34.8,c,40,Halton2021,1,13.4,c,30,Ottawa2021,9,342,m,20,Kenora2021,1,51.7,c,20,Kenora2021,6,632,m,40,Halton2021,5,78.1,c,20,Kenora2021,12,76.2,c,10,Essex2021,8,470,m,30,Ottawa2021,7,693,m,30,Renfrew2021,1,28.3,c,30,Renfrew2021,8,799,m,40,Simcoe2021,11,636,m,30,Ottawa2021,12,504,m,40,Halton2021,8,46.6,c,30,Renfrew2021,9,584,m,30,Renfrew2021,6,23,m,40,Simcoe2021,6,40.9,c,20,Thunder Bay2021,2,487,m,30,Renfrew2021,3,58.8,c,20,Kenora2021,2,65.6,c,20,Kenora2021,6,53.3,c,10,Essex2021,10,57.6,c,10,Chatham-Kent2021,9,50,c,10,Essex2021,4,193,m,10,Essex2021,1,740,m,40,Halton2021,3,64.5,c,30,Ottawa2021,7,162,m,10,Essex2021,8,18.3,c,20,Kenora2021,1,35.4,c,20,Thunder Bay2021,2,94,c,10,Essex2021,7,64.3,c,20,Kenora2021,10,9,c,40,Simcoe2021,10,43.8,c,30,Ottawa2021,8,4.1,c,10,Essex2021,9,618,m,40,Simcoe2021,9,74.6,c,10,Chatham-Kent2021,10,428,m,10,Essex2021,5,739,m,30,Renfrew2021,2,22.9,c,40,Simcoe2021,4,739,m,40,Halton2021,1,25.9,c,10,Essex2021,5,55.5,c,20,Thunder Bay2021,10,65.3,c,30,Renfrew2021,3,207,m,10,Essex2021,12,74.7,c,30,Renfrew2021,5,69.1,c,10,Essex2021,8,16.8,c,20,Thunder Bay2021,4,297,m,20,Thunder Bay2021,6,76.8,c,10,Chatham-Kent2021,3,43,c,40,Simcoe2021,5,33,c,40,Halton2021,2,482,m,20,Thunder Bay2021,11,163,m,10,Essex2021,11,6.3,c,30,Renfrew2021,7,21.8,c,30,Ottawa2021,5,29,c,40,Simcoe2021,5,77.7,c,10,Chatham-Kent2021,4,65.6,c,10,Chatham-Kent2021,2,146,m,30,Ottawa2021,4,149,m,40,Simcoe2021,6,15.9,c,30,Ottawa2021,10,33.8,c,20,Kenora2021,2,542,m,40,Halton2021,1,759,m,10,Chatham-Kent2021,3,760,m,10,Chatham-Kent2021,4,602,m,30,Renfrew2021,11,745,m,40,Halton2021,3,20.9,c,30,Renfrew Expected-Output.txt======================================================= Ontario Weather Analysis Service Year: 2021=======================================================1. View all data2. View by region (sorted DESCENDING by precip.)3. View by month (sorted ASCENDING by precip.)4. View by location name (sorted DESCENDING by precip.)-------------------------------------------------------0. Exit-------------------------------------------------------Selection: 1Year Month Precip.Amt Unit Region Name---- ----- ---------- ---- ------ ---------------2021 12 45.2 c 30 Ottawa2021 03 743.0 m 40 Halton2021 04 32.9 c 30 Ottawa2021 07 8.2 c 20 Thunder Bay2021 12 133.0 m 20 Kenora2021 06 106.0 m 30 Renfrew2021 01 646.0 m 40 Simcoe2021 11 72.2 c 10 Chatham-Kent2021 10 257.0 m 20 Thunder Bay2021 12 54.8 c 10 Chatham-Kent2021 11 61.5 c 40 Simcoe2021 02 18.8 c 10 Chatham-Kent2021 11 47.6 c 20 Kenora2021 12 57.5 c 20 Thunder Bay2021 09 28.1 c 20 Thunder Bay< Press [ENTER] key to continue >2021 05 326.0 m 30 Ottawa2021 07 376.0 m 40 Simcoe2021 10 515.0 m 40 Halton2021 08 76.9 c 10 Chatham-Kent2021 12 635.0 m 40 Simcoe2021 07 350.0 m 10 Chatham-Kent2021 09 48.9 c 30 Ottawa2021 11 13.5 c 20 Thunder Bay2021 06 143.0 m 20 Kenora2021 04 614.0 m 20 Kenora2021 03 299.0 m 20 Thunder Bay2021 09 672.0 m 40 Halton2021 07 71.7 c 40 Halton2021 08 34.8 c 40 Halton2021 01 13.4 c 30 Ottawa< Press [ENTER] key to continue >2021 09 342.0 m 20 Kenora2021 01 51.7 c 20 Kenora2021 06 632.0 m 40 Halton2021 05 78.1 c 20 Kenora2021 12 76.2 c 10 Essex2021 08 470.0 m 30 Ottawa2021 07 693.0 m 30 Renfrew2021 01 28.3 c 30 Renfrew2021 08 799.0 m 40 Simcoe2021 11 636.0 m 30 Ottawa2021 12 504.0 m 40 Halton2021 08 46.6 c 30 Renfrew2021 09 584.0 m 30 Renfrew2021 06 23.0 m 40 Simcoe2021 06 40.9 c 20 Thunder Bay< Press [ENTER] key to continue >2021 02 487.0 m 30 Renfrew2021 03 58.8 c 20 Kenora2021 02 65.6 c 20 Kenora2021 06 53.3 c 10 Essex2021 10 57.6 c 10 Chatham-Kent2021 09 50.0 c 10 Essex2021 04 193.0 m 10 Essex2021 01 740.0 m 40 Halton2021 03 64.5 c 30 Ottawa2021 07 162.0 m 10 Essex2021 08 18.3 c 20 Kenora2021 01 35.4 c 20 Thunder Bay2021 02 94.0 c 10 Essex2021 07 64.3 c 20 Kenora2021 10 9.0 c 40 Simcoe< Press [ENTER] key to continue >2021 10 43.8 c 30 Ottawa2021 08 4.1 c 10 Essex2021 09 618.0 m 40 Simcoe2021 09 74.6 c 10 Chatham-Kent2021 10 428.0 m 10 Essex2021 05 739.0 m 30 Renfrew2021 02 22.9 c 40 Simcoe2021 04 739.0 m 40 Halton2021 01 25.9 c 10 Essex2021 05 55.5 c 20 Thunder Bay2021 10 65.3 c 30 Renfrew2021 03 207.0 m 10 Essex2021 12 74.7 c 30 Renfrew2021 05 69.1 c 10 Essex2021 08 16.8 c 20 Thunder Bay< Press [ENTER] key to continue >2021 04 297.0 m 20 Thunder Bay2021 06 76.8 c 10 Chatham-Kent2021 03 43.0 c 40 Simcoe2021 05 33.0 c 40 Halton2021 02 482.0 m 20 Thunder Bay2021 11 163.0 m 10 Essex2021 11 6.3 c 30 Renfrew2021 07 21.8 c 30 Ottawa2021 05 29.0 c 40 Simcoe2021 05 77.7 c 10 Chatham-Kent2021 04 65.6 c 10 Chatham-Kent2021 02 146.0 m 30 Ottawa2021 04 149.0 m 40 Simcoe2021 06 15.9 c 30 Ottawa2021 10 33.8 c 20 Kenora< Press [ENTER] key to continue >2021 02 542.0 m 40 Halton2021 01 759.0 m 10 Chatham-Kent2021 03 760.0 m 10 Chatham-Kent2021 04 602.0 m 30 Renfrew2021 11 745.0 m 40 Halton2021 03 20.9 c 30 Renfrew======================================================= Ontario Weather Analysis Service Year: 2021=======================================================1. View all data2. View by region (sorted DESCENDING by precip.)3. View by month (sorted ASCENDING by precip.)4. View by location name (sorted DESCENDING by precip.)——————————————————-0. Exit——————————————————-Selection: 2Region Name Precip(mm)—— ——– ———- 10 Western 12498 40 Central 12127 30 Eastern 10074 20 Northern 9308—— ——– ———- Total: 44007 Average: 11001.75======================================================= Ontario Weather Analysis Service Year: 2021=======================================================1. View all data2. View by region (sorted DESCENDING by precip.)3. View by month (sorted ASCENDING by precip.)4. View by location name (sorted DESCENDING by precip.)——————————————————-0. Exit——————————————————-Selection: 3Month Precip(mm)——— ———-June 2773July 3241August 3244October 3295November 3555April 3579February 3670January 3692March 3881September 4232December 4356May 4489——— ———- Total: 44007Average: 3667.25======================================================= Ontario Weather Analysis Service Year: 2021=======================================================1. View all data2. View by region (sorted DESCENDING by precip.)3. View by month (sorted ASCENDING by precip.)4. View by location name (sorted DESCENDING by precip.)——————————————————-0. Exit——————————————————-Selection: 4Location Precip(mm)————— ———- Chatham-Kent 7619 Halton 7227 Renfrew 5632 Kenora 5414 Simcoe 4900 Essex 4879 Ottawa 4442 Thunder Bay 3894————— ———- Total: 44007 Average: 5500.88======================================================= Ontario Weather Analysis Service Year: 2021=======================================================1. View all data2. View by region (sorted DESCENDING by precip.)3. View by month (sorted ASCENDING by precip.)4. View by location name (sorted DESCENDING by precip.)——————————————————-0. Exit——————————————————-Selection: 0Application Terminated! Computer Science Engineering & Technology C++ Programming CSC 108 Share QuestionEmailCopy link Comments (0)


