98 867
Assignments Done
98.6%
Successfully Done
In April 2021

Answer to Question #16204 in C# for valarie

Question #16204
Create a program that will prompt an end user to input 5 float-type values, then calculate the mean, the variance and the standard deviation. I am so lost, need any help avaiable.
1
2012-10-11T09:49:51-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
double[] array1 = new double[5];
for (int i = 0; i < 5; i++)
{
Console.Write("Enter value for " + (i + 1).ToString() + ": ");
}
Console.WriteLine("Mean= " + ArithmeticMean(array1, 5).ToString());
Console.WriteLine("Standard Deviation= " + StandardDeviation(array1, 5).ToString());
Console.WriteLine("Variance= " + Variance(array1, 5).ToString());
}

static double StandardDeviation(double[] data, int items)
{
int i;
double SD, mean, devMean;
double[] deviation = new double[items];

mean = ArithmeticMean(data, items);

for (i = 0; i < items; i++)
{
deviation[i] = Math.Pow((data[i] - mean), 2);
}

devMean = ArithmeticMean(deviation, items);
SD = Math.Sqrt(devMean);

return SD;
}
static double ArithmeticMean(double[] data, int items)
{
int i;
double mean, sum;

sum = 0.0;

for (i = 0; i < items; i++)
{
sum += data[i];
}

mean = sum / (double)items;
return mean;
}
static double Variance(double[] data, int items)
{
int i;
double variance, mean;

double[] deviation = new double[items];

mean = ArithmeticMean(data, items);

for (i = 0; i < items; i++)
{
deviation[i] = Math.Pow((data[i] - mean), 2);
}

variance = ArithmeticMean(deviation, items);

return variance;
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!