using System;
using System.Collections.Generic;
using System.IO;

public class SalesValues
{
    private List<int> values;      // Verkaufszahlen der letzten Jahre

    public SalesValues()
    {
        values = new List<int>(10);
        StreamReader sr = File.OpenText("salesdata.txt");

        string line = "";

        while (sr.Peek() != -1)
        {
            line = sr.ReadLine();
            values.Add(Convert.ToInt32(line));
        }

        sr.Close();
    }

    public double MeanValue
    {
        get
        {
            int sum = 0;
            foreach (int i in values)
                sum += i;

            return sum / values.Count;
        }
    }
    
    public int Size
    {
        get
        {
            return values.Count;
        }
    }

    // Indexer, der Zugriff auf Werte des internen Arrays vermittelt
    public int this[int index]
    {
        get
        {
            if (index >= 0 && index < 10)
                return values[index];
            else
                throw new IndexOutOfRangeException();
        }
    }
}


public class Program
{
    static void Main()
    {
        SalesValues sv = new SalesValues();

        for (int i = 0; i < sv.Size; i++)
            Console.WriteLine(sv[i]);

        Console.WriteLine("\n Mittelwert: {0}", sv.MeanValue);
    }
}