Hello, I need some help with a couple of if statements regarding a text file. I have data in a text.file like this:
33 60 0.6
26 65 0
33 70 0
I am suppose to tell the highest temp, and lowest temp(first two columns) third is rain . The program will pick out the lowest number in the low, and highest in the high and display, then it will average for an average low and average high. The rain will be added, and each row is a day.
I have my code started, but not sure how to create if statements regarding textfiles at all. Any help would be greatly appreciated! My code so far prints out the data not sure what to do next.
Actually the most difficult part you have done already. You opened the file and read all the lines into their different parts. Now you just need to process the input; to get the min temperature you would do sth like this:
1 2 3 4 5 6 7 8 9 10 11 12
int MinTemp = 60; // estimated max value
while(weatherfile >> minlow >> minhigh >> rain)
{
//cout << minlow<< " "<< minhigh << " "<< rain << endl;
if (minlow < MinTemp)
{
MinTemp = minlow;
}
}
cout << "Minimum temperature = " << MinTemp << endl;