Codigo:
namespace practica_10_problema_1_visual
{
public partial class Form1 : Form
{
int[] resistencia;
double[] corriente;
double[] potencia;
int i;
double suma;
public Form1()
{
InitializeComponent();
resistencia=new int[5]{16,27,39,56,81};
corriente = new double[5];
potencia = new double[5];
i = 0;
suma = 0;
listBox1.Items.Add("Resisencia\tCorriente\t\tPotencia");
listBox1.Items.Add(" ");
}
private void button1_Click(object sender, EventArgs e)
{
if (i <= 4)
{
corriente[i] = double.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
i++;
}
if (i == 5)
{
textBox1.Enabled = false;
button1.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
for (i = 0; i <= 4; i = i + 1)
{
potencia[i] = resistencia[i] * Math.Pow(corriente[i], 2);
suma = suma + potencia[i];
listBox1.Items.Add(resistencia[i] + "\t\t" + corriente[i] + "\t\t" + potencia[i]);
listBox1.Items.Add(" ");
}
listBox1.Items.Add("===================================================");
listBox1.Items.Add("Potencia total= " + suma);
}
private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox1.Enabled = true;
button1.Enabled = true;
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
miércoles, 21 de abril de 2010
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario