REAL[] resistencia ={16,27,39,56,81};
REAL[] corriente = new int [5];
REAL[] potencia = new int[5];
REAL total = 0, I = 0;
for (I = 0 TO 4 STEP I=I+1)
{
PRINT("Introduce corriente",I);
READ corriente[I]
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
total = total + potencia[I];
}
PRINT(" Resistencia Corriente Potencia");
PRINT("________________________________________________");
for (I = 0 TO 4 STEP I=I+1)
{
PRINT(" {0} {1} {2}", resistencia[I], corriente[I], potencia[I]);
}
PRINT("Total= " + total);
FINAL
CODIGO EN CONSOLA:
static void Main(string[] args)
{
int [] resistencia ={16,27,39,56,81};
int[] corriente = new int [5];
int[] potencia = new int[5];
int total = 0, I = 0;
for (I = 0; I <= 4; I++)
{
Console.WriteLine("Introduce corriente",I);
corriente[I] = int.Parse(Console.ReadLine());
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
total = total + potencia[I];
}
Console.WriteLine(" Resistencia Corriente Potencia");
Console.WriteLine("________________________________________________");
for (I = 0; I <= 4; I++)
{
Console.WriteLine(" {0} {1} {2}", resistencia[I], corriente[I], potencia[I]);
}
Console.WriteLine("Total= " + total);
Console.ReadKey();
}
.bmp)
CODIGO EN 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