![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2i0f2Ua_ssg5Ai9wU64yBDRr3Sn3gk1oBH7mAXqUOG2kJb4R_aItt8VZ2jlx_Voov4WkGFjRo89PQCWDLeGBYuYjrP_BNeq3DWlkspmCHXk79HAo25Cf64YiQ0TGbQcuxiAYCbQWQ2yaE/s400/PRACTICA+2.jpg)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace practica_2_visual
{
public partial class frmpractica2visual : Form
{
public frmpractica2visual()
{
InitializeComponent();
}
double[] corriente = new double[10];
double[] resistencia = new double[10] { 26, 40, 44, 50, 66, 89, 10, 32, 5, 18 };
double[] potencia = new double[10];
int i = 0;
double total = 0;
private void cmdcorriente_Click(object sender, EventArgs e)
{ //DIAZ CABALLERO JOSE SALVADOR
//PROGRAMACION ORIENTADA A OBJETOS
//PROFESORA COLUNGA
// PRACTICA 2
//asigancion de valores a variables
corriente[i]= double.Parse(txtcorriente.Text);
lstcorriente.Items.Add(corriente[i].ToString());
txtcorriente.Clear();
txtcorriente.Focus();
i++;
// condicion para cuando termine el ciclo de capturar, cacula potencia y total y aguega a las listas datos
if ( i ==10){
txtcorriente.Enabled=false;
cmdcorriente.Enabled=false;
for( i=0; i<10; i++){
potencia[i]= resistencia[i] * (Math.Pow(corriente[i] , 2));
total=total+ potencia[i];
lstpotencia.Items.Add(potencia[i].ToString());
lstresistencia.Items.Add(resistencia[i].ToString());
}
lblTotal.Text= "el total es: "+ total.ToString();
}
}
private void cmdLimpiar_Click(object sender, EventArgs e)
{
cmdcorriente.Enabled = true;
txtcorriente.Enabled = true;
lstresistencia.Items.Clear();
lstcorriente.Items.Clear();
lstpotencia.Items.Clear();
txtcorriente.Focus();
lblTotal.Text = "";
}
private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}
}
}
No comments:
Post a Comment