Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions