Örneğin Kodları :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace diziye_al
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
int[] sayilar = new int[listBox1.Items.Count];
for (int i = 0; i < listBox1.Items.Count; i++)
{
sayilar[i]=Convert.ToInt32(listBox1.Items[i].ToString());
listBox2.Items.Add(listBox1.Items[i].ToString());
}
}
private void button3_Click(object sender, EventArgs e)
{
int[] sayilar = new int[listBox2.Items.Count];
double toplam = 0;
for (int i = 0; i < listBox2.Items.Count; i++)
{
sayilar[i]=Convert.ToInt32(listBox2.Items[i].ToString());
toplam+=sayilar[i];
}
textBox2.Text = toplam.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
int[] sayilar = new int[listBox2.Items.Count];
double toplam = 0;
for (int i = 0; i < listBox2.Items.Count; i++)
{
sayilar[i] = Convert.ToInt32(listBox2.Items[i].ToString());
toplam += sayilar[i];
}
double ortalama = toplam / sayilar.Length;
textBox3.Text = ortalama.ToString();
//Erdoğan GENÇTÜRK.
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Hiç yorum yok:
Yorum Gönder