Getting funky readouts with my while loop

i have a .txt file with some data, an example would be like this

Monday 100 50
Tuesday 50 32
Wednesday 10 5
Thursday 70 65

where it shows the day, high temperature, and low temperature. I need to make a while loop to collect the high and low temperatures, and make an average. My code

while (inputFile >> day) //continue loop while data is entered into string day
inputFile >> day; //enter in the day
inputFile >> tempHigh; //enter in the high temp
inputFile >> tempLow; //enter in the low temp
counter++; //keep a running total of how many days are recorded
highTotal += tempHigh; //totaling up the high temperature for average 
lowTotal += tempLow; //totaling up the low temperature for averages 

after that i close the while loop, do the calculations for the average, then have a cout to show the results, but it only records 2 days, and the numbers i am getting for the averages are a high of 2.25 and a low of 4.somethingsomethingsomethingE+numbers

where did the loop fail?
┬┐why are you reading into `day' twice?

while( input>>day>>high>>low ){
not sure what you mean by reading into 'day' twice.
though i did try your suggestion of changing the conditions and i got a much sensible result.
However the loop still cut short. My .txt file has 56 days listed but the loop only recorded 29 days.

Edit: Nevermind realized what you meant and deleted line 3,4, and 5. Origionally i thought that the condition read the data just to check it. Didnt realize that it also stored the data into the variables.

the count being off was an unrelated error. I believed this solved my issue, thanks ne555!
Last edited on
Topic archived. No new replies allowed.