title: Display sum and average of numbers 1 to 100
body: <p>I am trying to write a simple program in C# to display the sum and the average of the numbers 1 to 100. the output should look like...</p>
  
  <pre><code>the sum is 5050
  the average is 50.5
  </code></pre>
  
  <p>I cant seem to get it to work properly though, the return value only returns the sum not the wording before it, I have tried other ways for it to display the message and sum and ave but they arent working. I am trying to do this using the model view view controller method, but cant understand where I am going wrong and how to get it to display the above result. my code is below.</p>
  
  <pre><code>class SumAndAverage
  {
      public float sum = 0;
      public float ave = 0;
  
  
      public float SumAndAve()
      {
  
          for (int i = 1; i &lt;= 100; i++)
          {
              sum = sum + i;
              ave = sum / i;
          }
  
          return sum + ave;
  
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>class SumAndAverageController
  {
      IView view;
      SumAndAverage sumAndAverage;
      public SumAndAverageController(IView theView, SumAndAverage theSumAndAverage){
      view = theView;
      sumAndAverage = theSumAndAverage;
  }
      public void Go()
      {
          view.Start();
          //mAndAverage.SetNumber(view.GetString("Please enter a number"));
          view.Show(sumAndAverage.SumAndAve());
          //view.Show(sumAndAverage.Result());
          view.Stop();
      }
  }
  
  
  class ConsoleView : IView
  {
      public void Start()
      {
          Console.Clear();
      }
  
      public void Stop()
      {
          Console.WriteLine("Press any key to continue");
          Console.ReadKey();
      }
  
  
  
      public void Show&lt;T&gt;(T message)
      {
          Console.WriteLine(message);
      }
  
  }
  
  
  interface IView
  {
      void Start();
      void Stop();
      void Show&lt;T&gt;(T message);
  }
  
  
  class Program
  {
      static void Main(string[] args)
      {
  
          new SumAndAverageController(new ConsoleView(), new SumAndAverage()).Go();
      }
  }
  </code></pre>