07-31-2002, 06:43 AM
Thank you very much for your help. I've got a text file with the following
numbers displayed as such:
I would like to have output that looks like this:
Ave. = 18.33
Ave. = 23.33
I've tried a number of different angles with no luck. All help would be
07-31-2002, 10:37 AM
Showing us what you have so far would've been better because we could just edit your code instead of having to come up with an entirely new one. I'm just going to give you the algorithm for what to do and hopefully you'll be able to do it.
Start off by setting something like $sum1, $sum2, and $count all equal to 0. Then also create two arrays $vals1 and $val2 with nothing in them. Obviously, you've got to read the contents of the file line by line. And when you get the contents of each line, you need to split it into two different variables with the split command. Add the first variable into $sum1 using the .= notation and add the second variable into $sum2. Then add the first variable into the current slot of the array ($vals1[$count] = $variable1) and do the same for the second variable. Then increment $count ($count++). You do this all inside the looping structure you use to read the contents of the file. Then after that dive the sum variables by $count and you have $av1 and $av2. Then just loop through each array ($vals1 and $vals2) displaying what's in each cell and then display the average at the end.
Does that help you out. I guess I could give you some actual code, but it'd probably be more beneficial for you if you can figure it out the rest on your own.
07-31-2002, 07:54 PM
I'll try it out. I really appreciate your help. Next time, I'll include code, too!