i want someone to do this assignment for me.. its only a question..
i need it in 6 hours..
(
3) Write a C++ program that calculates the average of measurements of Oak tree leaves.The measurements are in a text file called oakIn.txt. The file is provided to you on the blackboard. Follow the following requirements
1. Declare an array to hold the data in the main() program.
2. Write a function to read the data from the file into that array (ReadFile()) and call it from main(). The function should return TRUE if the file was successfully opened and read. It should return FALSE otherwise; i.e. if it encounters any problem.
3. Write a function called FindAve() that returns the average of the leaves’ measurements stored in the array. Call this function from main() and pass it the array that contains the data.
4.Within main(), after data is read in and average leave length is calculated, write code that opens an output file named oakOut.txt and writes into it a statement that includes the calculated leaves average length value; something like this
Average leaves length was calculated to be x.xxx.
)
the input file for this assignment..
is
CPP Phone Company John Doe 2016 12.4 23.1 34.6 32.4 52.3 21.5 23.7 45.3 23.4 51.3 45.2 23.7
i have almost done the program because i have an example of it. i did some changes on it. all i need is editing and making sure about the required output.. if you are expert enough it won't take more than 15 mins!!!!
here is the program for the example i have..
----------------------------
#include <string>
#include <fstream>
#include <iostream>
usingnamespacestd;
#define FILE_IN “oakIn.txt”
#define FILE_OUT “oakInAverage.txt”
bool ReadFile(float Oak_measurements[], string &rwidth, string &rheight);
bool FindAve(string height, string width, float sum, float ave);
int main()
{
float Oak_measurements[12], sum = 0.0, ave = 0.0;
string height, width;
bool rc;
rc = ReadFile(Oak_measurements, width, height);
for (int i = 0; i < 12; ++i)
{
sum += Oak_measurements[i];
}
ave = sum / static_cast<float>(12.0);
rc = FindAve(height, width, sum, ave);
getchar();
return(0);
}
bool ReadFile(float measurements[], string &rwidth, string &rheight)
{
ifstream oakInput;
oakInput.open(FILE_IN);
if (!oakInput)
{
cout << “n Failed to open file “ << FILE_IN;
returnfalse;
}
getline(oakInput, rheight);
getline(oakInput, rwidth);
for (int i = 0; i < 12; ++i)
{
oakInput >> measurements[i];
}
oakInput.close();
returntrue;
}
bool FindAve(string height, string width, float sum, float ave)
{
ofstream oakOutput;
oakOutput.open(FILE_OUT);
if (!oakOutput)
{
cout << “n Failed to open file “ << FILE_OUT;
returnfalse;
}
oakOutput << “nAverage leaves length was calculated to be: “ << ave;
oakOutput.close();
returntrue;
}
thank you,








Jermaine Byrant
Nicole Johnson



