Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can any one help with this: it is c++ . Temperature Statistics A file gives all

ID: 640864 • Letter: C

Question

Can any one help with this:

it is c++

. Temperature Statistics A file gives all of the temperatures for a period of time. Each number in the file is the temperature for 1 day. The number of days could be a month, a year, or the duration of a trip. You are to read in all of the temperatures from the file and print the following statistics: The number of days The temperature range, example: The temperatures ranged from -5 to 45 The average temperature The number of days (if any) that were freezing (32 degrees or less). Don't print if 0! The number of days (if any) that were 100 degrees or more. Don't print if 0

Explanation / Answer

#include <iostream>
#include <fstream>
int main(int argc, char * argv[])
{
    std::fstream myfile("D:\data.txt", std::ios_base::in);
   float a[10];
   int i=0;
    float b;
    while (myfile >> b)
    {
        printf("%f ", b);
        a[i]=b;
        i++;
    }
    int j=0;
    int cnt=0;
    int cn=0;
    int freeze=0;
for(j=0;j<i;j++)
{
   if(a[j]>-5||a[j]<45)
   {
   cnt++;
   }
   else if(a[j]>=100)
   {
       cn++;
   }
   if(a[j]<32)
   freeze++;
  
}

getchar();

    return 0;
}