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

Try to code based on the criteria. Use only one D array (one dimensional) array.

ID: 3690429 • Letter: T

Question

Try to code based on the criteria. Use only one D array (one dimensional) array. There is a text file and it does contain 8760 lines of data. Here is the link of the data which is better than copying all the numbers for this question

http://wikisend.com/download/130604/HIdata.txt

1. (100 pts) Write a program that will read "HIdata.txt," (on Learn) an 8760 file containing the projected output of and 11 MW 8760 data estimates, each data point represents a projected output for every hour of every day (hence 365x24-8760). Your task is to read in this.txt file and output a.txt file named Analysis.txt" that will look like this: AC power plant located in Waipio Hawaii. This file contains Fle Edit Format ew Heb AVG VAR STD MIN MAX 56862.45 64327.82 69596. 57 76492.08 79012. 52 81513. 11 81505. 83 80573. 58 76749. 84 67611.29 9522.92 54979. 46 222693903.75 227878003.95 285490409.92 236226793.45 159341964.13 94360267.89 98806211.96 156230071.74 148455888.79 153272482.06 165676900.06 187481856. 24 14922.93 15095. 63 16896.46 15369. 67 12623.07 9713.92 9940.13 12499. 20 12184.25 12380. 33 12871.55 13692.40 13603.48 24736. 24 15067.44 35165. 85 49936. 60 53467.18 57407.27 36441.26 40048. 52 32650. 28 24774.74 18375, 63 73462.76 81602.67 88307. 35 90661. 38 92363.75 92871. 38 92075. 37 90567. 88 89187.24 82287.42 74754.42 68592.90 DAN FEB AR UN UL SEP NOV DEC For this assignment, YOU MUST . Create an array for each month jan[], febll, marl,. decll o Each array should be the size of its corresponding month o Each array element should contain the total projection for that day o You do not need to re-invent the wheel, you may use any functions defined in o You are encourage to write any additional functions Find the average, variance, standard deviation, min, and max for each array . class

Explanation / Answer

#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <math.h>
using namespace std;

double mean(double month[], int low, int high)
{
   double sum = 0.0;
   for (int i = low; i < high; ++i)
   {
       sum = sum + month[i];
   }

   return sum/(high-low);
}

long double variance(double month[], int low, int high)
{
   double average = mean(month,low,high);
   long double sum = 0.0;
   for (int i = low; i < high; ++i)
   {
       sum = sum + pow((month[i] - average), 2);
   }

   return sum/(high-low);

}

double long std_deviation(double month[], int low, int high)
{
   long double var = variance(month,low,high);
   long double sd = sqrt(var);
   return sd;
}

double maximum(double month[], int low, int high)
{
   double maximum = month[low];
   for (int i = low; i < high; ++i)
   {
       if (month[i] > maximum)
       {
           maximum = month[i];
       }
   }

   return maximum;
}


double minimum(double month[], int low, int high)
{
   double minimum = month[low];
   for (int i = low; i < high; ++i)
   {
       if (month[i] < minimum)
       {
           minimum = month[i];
       }
   }

   return minimum;
}

int main()
{
   int january = 744;
   int february = january + 672;
   int march = february + 744;
   int april = march + 720;
   int may = april + 744;
   int june = may + 720;
   int july = june + 744;
   int august = july + 744;
   int september = august + 720;
   int october = september + 744;
   int november = october + 720;
   int december = november + 744;

   double total[8760];

ifstream file_("HLData.txt"); // opening HLData.txt

int i = 0;
double number;

while(file_ >> number)
{
    total[i] = number;
    i++;   
}

  
file_.close(); // closing HLData.txt
  

ofstream file("analysis.txt"); // opening file analysis.txt
file << " AVG VAR STD MIN MAX ";
file << "----------------------------------------------------------------------- ";
file << "JAN " << mean(total,0,january) << " " << variance(total,0,january) << " " << std_deviation(total,0,january) << " " << minimum(total,0,january) << " " << maximum(total,0,january) << endl;
file << "FEB " << mean(total,january,february) << " " << variance(total,january,february) << " " << std_deviation(total,january,february) << " " << minimum(total,january,february) << " " << maximum(total,january,february) << endl;
file << "MAR " << mean(total,february,march) << " " << variance(total,february,march) << " " << std_deviation(total,february,march) << " " << minimum(total,february,march) << " " << maximum(total,february,march) << endl;
file << "APR " << mean(total,march,april) << " " << variance(total,march,april) << " " << std_deviation(total,march,april) << " " << minimum(total,march,april) << " " << maximum(total,march,april) << endl;
file << "MAY " << mean(total,april,may) << " " << variance(total,april,may) << " " << std_deviation(total,april,may) << " " << minimum(total,april,may) << " " << maximum(total,april,may) << endl;
file << "JUN " << mean(total,may,june) << " " << variance(total,may,june) << " " << std_deviation(total,may,june) << " " << minimum(total,may,june) << " " << maximum(total,may,june) << endl;
file << "JUL " << mean(total,june,july) << " " << variance(total,june,july) << " " << std_deviation(total,june,july) << " " << minimum(total,june,july) << " " << maximum(total,june,july) << endl;
file << "AUG " << mean(total,july,august) << " " << variance(total,july,august) << " " << std_deviation(total,july,august) << " " << minimum(total,july,august) << " " << maximum(total,july,august) << endl;
file << "SEP " << mean(total,august,september) << " " << variance(total,august,september) << " " << std_deviation(total,august,september) << " " << minimum(total,august,september) << " " << maximum(total,august,september) << endl;
file << "OCT " << mean(total,september,october) << " " << variance(total,september,october) << " " << std_deviation(total,september,october) << " " << minimum(total,september,october) << " " << maximum(total,september,october) << endl;
file << "NOW " << mean(total,october,november) << " " << variance(total,october,november) << " " << std_deviation(total,october,november) << " " << minimum(total,october,november) << " " << maximum(total,october,november) << endl;
file << "DEC " << mean(total,november,december) << " " << variance(total,november,december) << " " << std_deviation(total,november,december) << " " << minimum(total,november,december) << " " << maximum(total,november,december) << endl;

file.close(); // closing analysis.txt

  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote