View Full Version : Averaging a list of numbers (reading .txt file)
isaaclloyd
06-15-2005, 06:33 AM
I am trying to get a single answer of averaged numbers from a list of numbers in a text file. The textfile looks like this:
1
3
8
5
6
3
1
1
3
etc.
I need the script to read each line (the number) and average them together. Any comments/suggestions would greatly be appreciated. Thanks.
~Isaac~
nikkiH
06-15-2005, 03:08 PM
This looks an awful lot like a homework assignment.
Doing your homework costs $20. ;)
(If it isn't homework, let us know, but this is pretty basic and easily found via a couple google searches for how to read a file and what the method is to get an average. Still have problems, tell us whether you want VB or C#.)
Bullschmidt
06-30-2005, 01:55 AM
And in general for each line have a running sum variable and a number of items variable that keeps getting updated. And at the end divide the running sum variable by the number of items variable.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.