martes, 10 de noviembre de 2009

10.3_voltajes[15]_consola y windows

PSEUDOCODIGO:
REAL[,] voltajes=new double[3,5];
REAL c1 =0,c2=0,r=0,c=0,suma1=0,suma2=0;
for (r = 0 TO 3 r=r+1)
{
for (c = 0 TO 5; c= c+1)
{
PRINT "Voltajes [{0},{1}] : ", r, c
READ voltajes[r, c]

}

}
for (r = 0 TO 3; r=r+1)
{
for (c = 0 TO 5; c=c+1)
{
if (voltajes[r, c] < 60)
{
c1 = c1 + 1;


}
else
{
if (voltajes[r, c] >= 60)
{


c2 = c2 + 1;

}
}
}
}
PRINT "No. de Voltajes <60 : {0} \n\n No. de Voltajes >=60 : {1}", c1,c2);



FINAL



CODIGO EN CONSOLA
static void Main(string[] args)
{

double[,] voltajes=new double[3,5];
int c1 =0,c2=0,r=0,c=0,suma1=0,suma2=0;
for (r = 0; r < 3; r++)
{
for (c = 0; c < 5; c++)
{
Console.Write("Voltajes [{0},{1}] : ", r, c);
voltajes[r, c] = double.Parse(Console.ReadLine());

}

}
for (r = 0; r < 3; r++)
{
for (c = 0; c < 5; c++)
{
if (voltajes[r, c] < 60)
{
c1 = c1 + 1;


}
else
{
if (voltajes[r, c] >= 60)
{


c2 = c2 + 1;

}
}
}
}
Console.WriteLine("\nNo. de Voltajes <60 : {0}\n\nNo. de Voltajes >=60 : {1}", c1,c2);



Console.ReadKey();



}


CODIGO EN WINDOWS:
public partial class Form1 : Form
{ int[,] voltaje = new int[3,5];
int r = 0;
int resistencia = 0;
int corriente = 0;
int c1=0,c2=0;
public Form1()
{


InitializeComponent();

listBox1.Items.Add("VOLTAJES");


}

private void button1_Click(object sender, EventArgs e)
{
if (resistencia < 3)
{
if (corriente < 5)
{
voltaje[resistencia, corriente] = int.Parse(textBox1.Text);
listBox1.Items.Add("Voltaje [" + resistencia.ToString() + "," + corriente.ToString() + "] : " + voltaje[resistencia, corriente].ToString());
corriente++;
textBox1.Clear();
textBox1.Focus();
textBox1.Clear();
}
else
{
resistencia++;
corriente = 0;

}

}


}

private void button2_Click(object sender, EventArgs e)
{
for (resistencia = 0; resistencia < 3; resistencia++)
{
for (corriente = 0; corriente < 5; corriente++)
{
if (voltaje[resistencia, corriente] < 60)
{
c1 = c1 + 1;

}
else
{
if (voltaje[resistencia, corriente] >= 60)
{
c2 = c2 + 1;
}
}

}
}

label2.Text = ("Numero de Voltajes <60 es: " + c1.ToString());
label3.Text = ("Numero de Voltases >=60 es: " + c2.ToString());

}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox1.Focus();
listBox1.Items.Clear();
label2.Text = "";
label3.Text = "";

}

private void button4_Click(object sender, EventArgs e)
{
Application.Exit();
}
}

No hay comentarios:

Publicar un comentario