I am making a program that will take the input of x amount of numbers on oneline that it will calculate the amount of data, and growth, and average. The average of the tree growth will be compared to each value. So if the average is 3inches and the tree grew one inch, the program will say the tree grew 1 inch which is -2 away from the average. I have the program started, but have no clue what to do next. Thank you for any help.
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
usingnamespace std;
void weatherfunction(ifstream&);//function prototype says that ifstream will be used in the function
int main()
{
ifstream weatherfile("tree.txt");//allows file to be opened
weatherfunction(weatherfile);//tells the program that the tree will be used and opened in this file.
weatherfile.close();//closes treefile
return 0;//return value at the end.
}
void weatherfunction(ifstream& file)//allows file to be opened, and used with ifstream&. The ifstream says it will be a treefile.
{
if (!weatherfile)//if statement to check if the file has opened correctly
{
cout<<"Please try again, unable to open text file"<<endl;//output if file does not open correctly
}