Write a program that reads daily weather data for a month, and finds the average
ID: 675401 • Letter: W
Question
Write a program that reads daily weather data for a month, and finds the average monthly temperature based on the daily average temperature. The data file, May_2015.txt, contains a line of data for each day of the month beginning with the day number followed by 31 separate measurements/observations. The 4th column contains the average temperature for the day. The 9th column contains a 1 if the day was foggy and a 0 for clear days. Write a program to read the average daily temperature and determine if the day was foggy. Sum the daily average temperature to calculate a monthly average and count the number of foggy days per month. Although the given data file is for the merry, merry month of May, write your program so that it will read the data for any month. Open an output file and write the day number in the first column, the average daily temperature in the second column, and in the third column a F if the day was foggy or a C if it was clear. At the end, output the average monthly temperature and the number of foggy days.
Consider that we need to read the value in each column to increment the position in the file, but if we don’t need the value in a particular column, why save it? We can just create a throwaway variable and overwrite it continuously until we arrive at a value of interest. This is essentially a counting problem. Hint: use two loops. Remember that your program must work for any month.
Explanation / Answer
CODE :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.