miércoles, 9 de diciembre de 2009

PRACTICA 10.2 WINDOWS


public partial class Form1 : Form
{
int[] resistencia = { 16, 27, 39, 56, 81 };
int [] corriente = new int[5];
int[] potencia = new int[5];
int total = 0, I = 0;

public Form1()
{
InitializeComponent();
total = 0;
listBox1.Items.Add("RESISTENCIA");
listBox2.Items.Add("CORRIENTE");
listBox3.Items.Add("POTENCIA");
}

private void button1_Click(object sender, EventArgs e)
{


if (I < 5)
{
textBox1.Focus();
corriente[I] = int.Parse(textBox1.Text);
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
textBox1.Clear();
total = total + potencia[I];
listBox1.Items.Add(resistencia[I]);
listBox2.Items.Add(corriente[I]);
listBox3.Items.Add(potencia[I]);
I++;

}

else
{
button1.Enabled = false;
}
}

private void button2_Click(object sender, EventArgs e)
{
label2.Text = (total.ToString());



}


No hay comentarios:

Publicar un comentario