average from input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

average from input

i have a .txt file from which I have to read some grades of students and calculate the average.

27th Sep 2016, 4:38 PM
Andrea Di Dio
Andrea Di Dio - avatar
3 Answers
0
Have one variable to store the sum of the grades, another one to count them, and update them each loop. At the end, the average is the first variable divided by the second.
27th Sep 2016, 4:45 PM
Zen
Zen - avatar
0
use filereader object to read data from text file. and store them in variables and then calculate using formula.
27th Sep 2016, 4:51 PM
Nick Silicon
Nick Silicon - avatar
0
save the text file as a .java file and run it from the cmd in Windows or download a compiler. I use the IDE eclipse for my programming. To do the sum create variables for each value and then a average variable to store your value in
27th Sep 2016, 4:55 PM
Joshua Parsons
Joshua Parsons - avatar