miércoles, 14 de abril de 2010

Practica 9 Problema 1 "En visual"

Codigo:


namespace practica_9_problema_1._1
{
public partial class Form1 : Form
{
int[] temp;
int i, total, prom;
public Form1()
{
InitializeComponent();
temp = new int[10];
i = total = prom = 0;

}

private void button1_Click(object sender, EventArgs e)
{
if (i < 10)
{
temp[i] = int.Parse(textBox1.Text);
total = total + temp[i];
listBox1.Items.Add("Valor " + i + ": " + temp[i]);
i++;
textBox1.Clear();
textBox1.Focus();
}
if (i == 10)
{
textBox1.Enabled = false;
button1.Enabled = false;
}


}

private void button2_Click(object sender, EventArgs e)
{
prom = total / 10;
listBox1.Items.Add(" ");
listBox1.Items.Add("Promedio= " + prom);
}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Enabled = true;
button1.Enabled = true;
listBox1.Items.Clear();
}

private void button4_Click(object sender, EventArgs e)
{
Close();


}
}
}

No hay comentarios:

Publicar un comentario