Calculate Average Score by Reading a File
Learn to read the content of a text file in Ruby and calculate the average score.
We'll cover the following...
Problem
Write a program that reads the content of a text file that contains scores of a class (0–100, one on each line) and calculates the average score.
Note: The calculated average score is rounded to one decimal point.
File format
The file contains integer values, each appearing on a separate line. Here's a sample file:
84787087
Format of the input file
Expected Output
With the above example, the average calculated would be as follows: ...