I'm trying to make the program able to receive more than one input and then give the results of all the imputs together. Sofar, rightnow I'm only able to input one number and the program will immediately print out the result. I want to continue to imput until I press y or n and then print out the results. Any help will be appreciated. What I have at this moment is the following.

[using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication00000007
{
class Program
{
public void Go()
{
int n;
double sum = 0.0, sumsquare = 0.0, mean = 0.0, var = 0.0;


Console.Write("Enter an integer: ");
n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
sum = sum + i;
sumsquare = sumsquare + i * i;
}
if (n > 0)
{
mean = sum / n;
var = (sumsquare - sum * sum / n) / n;


Console.WriteLine("The mean = " + mean);
Console.WriteLine("The variance = " + var);
}


}
static void Main(string[] args)
{
new Program().Go();
}
}
}]

before calling the method which compute the variance and the mean

string n = Console.ReadLine();
if( n == "y")
// exit
else
//parse and compute

Thanks Ramy,

I was also thinking of placing a while loop to continue accepting numbers until I ress a certain key to stop anc compute all and display the results.

I'll give it a try.
Any help is always appreciated.

Vincent

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.