Question: Create an application that reads this file's contents into an array, displays the array's contents in a list box control, and calculates and displays the

Create an application that reads this file's contents into an array, displays the array's contents in a list box control, and calculates and displays the total, average, min, and max of the array's values in a single label.

Sales.txt includes:

1245.67 1189.55 1098.72 1456.88 2109.34 1987.55 1872.36

I am able to display that file's contents in a list box but need help with the rest. Here is my code.

private void MainForm_Load(object sender, EventArgs e) { StreamReader inputFile;

inputFile = File.OpenText("Sales.txt");

int lineCount = File.ReadLines("Sales.txt").Count(); double[] numbers = new double[lineCount];

int index = 0; while (index < numbers.Length && !inputFile.EndOfStream) { numbers[index] = double.Parse(inputFile.ReadLine()); index++; }

inputFile.Close();

foreach (double number in numbers) { salesListBox.Items.Add(number); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!