array getting max/min value and average

June 15, 2009 at 09:36:12
Specs: Windows Vista
Hi, i need to make a program that reads in 10 numbers and then i have to get the lowest number, the highest number, the average and show all numbers below average.

what i got so far is this :

double[] waarden = new double[10];
waarden = Convert.ToDouble(invoer);


for (int i = 0; i < waarden.Length; i++)
{

waarden[i] = Convert.ToDouble(Console.ReadLine());

Console.WriteLine("this is the highest number till now" + Math.Max(?, ?));
Console.WriteLine("this is the lowest number till now" + Math.Min(i, i));

}

for (int i = 0; i < waarden.Length; i++)
{


waarden[i] = Convert.ToDouble(Console.ReadLine());


}

It shows the numbers i typed in but i cant get the highest and lowest cause it says i cant convert a double to double[] o.0

anyone can help?

thanks ;)


See More: array getting max/min value and average

Report •


#1
June 15, 2009 at 19:31:39

Report •

#2
June 16, 2009 at 04:27:35
Ah np i think i found it ;) i used another for loop

double maxwaarde = 0;
double minwaarde = 9999;
double opsomgetal = 0;
for (int i = 0; i < waarden.Length; i++)
{
if (waarden[i] > maxwaarde)
{
maxwaarde = waarden[i];
}
if (waarden[i] < minwaarde)
{
minwaarde = waarden[i];
}
opsomgetal += waarden[i];


Report •

Related Solutions


Ask Question