Question: Write a C++ program that reads in the data from daily_TEMP_2013_proc.txt which contains 7 columns. The 1st column is a State ID number. The 2nd

Write a C++ program that reads in the data from "daily_TEMP_2013_proc.txt" which contains 7 columns. The 1st column is a State ID number. The 2nd and 3rd columns are latitude and longitude values, respectively, where the temperature measurements were recorded in the year 2013. The 4th column is a date. The 5th column is the temperature measurement followed by the State name in the 6th and then the day of the year (i.e. January 1 is 1, February 1 is 32, etc.) in the 7th column. Your program should step through the file and compute the average yearly temperature for each state. Hints: You can make use of tempsum = tempsum + tempreadin; (or something similar) inside a while loop as shown in class and then take the average by dividing by N. Consider something similar with the Lat and Long values. This while loop can be inside a for loop which steps through the state IDs. Remember to reset N (the number of measurements) and other variables for each state if needed. The while loops exit criterion can be adjusted so that it allows exiting when your ifstream object has moved onto the next state. Be careful about dividing by 0 (i.e. N = 0) and use if statements if you need to check values. Extracting the date column (column 4) may require three values and extracting the State name will require a variable of type string. Experiment with different ways. Save the processed data to an output file. The output file should have four columns that represent respectively State ID, Lat, Long and Average Yearly Temperature. Note that some State ID do not exist (like 3 and 7 etc.).Your output file should look like this (with no header row). Note that State ID 3 doesnt exist): (Hint: You can graph the data to help debug if you want)

1 33.553056 -86.815 2013-01-01 11.05 Alabama 1 1 33.553056 -86.815 2013-01-02 3.945833 Alabama 2 1 33.553056 -86.815 2013-01-03 2.8 Alabama 3 1 33.553056 -86.815 2013-01-04 4.020833 Alabama 4 1 33.553056 -86.815 2013-01-05 4.327083 Alabama 5 1 33.553056 -86.815 2013-01-06 5.945833 Alabama 6 1 33.553056 -86.815 2013-01-07 5.191667 Alabama 7 1 33.553056 -86.815 2013-01-08 10.716667 Alabama 8 1 33.553056 -86.815 2013-01-09 13.408333 Alabama 9 1 33.553056 -86.815 2013-01-10 17.491667 Alabama 10
2 63.725344 -148.96573 2013-01-01 34.5 Alaska 1 2 63.725344 -148.96573 2013-01-02 29.5 Alaska 2 2 63.725344 -148.96573 2013-01-03 29.708333 Alaska 3 2 63.725344 -148.96573 2013-01-04 27.041667 Alaska 4 2 63.725344 -148.96573 2013-01-05 28.583333 Alaska 5 2 63.725344 -148.96573 2013-01-06 29.125 Alaska 6 2 63.725344 -148.96573 2013-01-07 23.416667 Alaska 7 2 63.725344 -148.96573 2013-01-08 5.916667 Alaska 8 2 63.725344 -148.96573 2013-01-09 7.666667 Alaska 9 2 63.725344 -148.96573 2013-01-10 18.375 Alaska 10 2 63.725344 -148.96573 2013-01-11 23.916667 Alaska 11 2 63.725344 -148.96573 2013-01-12 30.125 Alaska 12 2 63.725344 -148.96573 2013-01-13 36.583333 Alaska 13
4 32.117069 -109.46759 2013-01-01 31.208333 Arizona 1 4 32.117069 -109.46759 2013-01-02 37.833333 Arizona 2 4 32.117069 -109.46759 2013-01-03 32.625 Arizona 3 4 32.117069 -109.46759 2013-01-04 31.833333 Arizona 4 4 32.117069 -109.46759 2013-01-05 36.25 Arizona 5 4 32.117069 -109.46759 2013-01-06 40.416667 Arizona 6 4 32.117069 -109.46759 2013-01-07 42.375 Arizona 7 4 32.117069 -109.46759 2013-01-08 43.458333 Arizona 8 4 32.117069 -109.46759 2013-01-09 44.291667 Arizona 9 4 32.117069 -109.46759 2013-01-10 46.833333 Arizona 10 4 32.117069 -109.46759 2013-01-11 34.5 Arizona 11 4 32.117069 -109.46759 2013-01-12 22.875 Arizona 12

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!