http://i.stack.imgur.com/COOqs.png売上データのファイルから平均を計算しますか?
総売上
はSales.txtという名前の添付ファイルを使用してください。
は、ダブルまたは小数 ディスプレイListBoxコントロールの配列の内容の配列にファイルの内容を読み取り は、配列の値の合計を計算し、平均売上高、最大の売上高は、最小販売することを 合計を表示するアプリケーションを作成します。 フォームは次のようになります。
表示する画像の合計/平均/高/低売上高を表示するにはどうすればよいですか?対応するコード? 私は自分自身でこれをやりたいので、私が実際にやっていることに関係するかもしれない例を与えることができれば、本当に役に立ちます。 は、ここで私はこれまでのところまで入力することができましたものです:
namespace Total_Sales
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void displayButton_Click(object sender, EventArgs e)
{
//declaring array
const int SIZE = 100;
decimal[] sales = new decimal[SIZE];
//varible to hold amount stored in array
int count = 0;
decimal additionHolder = 0;
//declaring streamreader
StreamReader inputFile;
//opening the sales file
inputFile = File.OpenText("../../Sales.txt");
try
{
//pull contents from file into array while there is still items
//to pull and the array isnt full
while (!inputFile.EndOfStream && count < sales.Length)
{
sales[count] = decimal.Parse(inputFile.ReadLine());
count++;
}
//close the file
inputFile.Close();
//display contents in listbox
for (int index = 0; index < count; index++)
{
ListBox.Items.Add(sales[index]);
}
//add all the values
for (int index = 0; index < sales.Length; index++)
{
additionHolder += sales[index];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
リストを参照してください - >リスト内のファイルからすべてをロードします。その後、リストからリストボックスを塗りつぶします。 List.Sort()をソートします。 List.Sum()、List.Sum()/ List.Count() - > avg、既にソートされたリストList.First() - > lowest、List.Last()max要素。何かが明確でないか尋ねる –
mybirthname