martes, 17 de noviembre de 2009

Practica extra problema 3 visual


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace examen_2__Windows
{
public partial class Form1 : Form
{
double lim, peso, sum;
public Form1()
{
InitializeComponent();
sum = 0;
}

private void button1_Click(object sender, EventArgs e)
{
lim = double.Parse(textBox1.Text);
listBox1.Items.Add("\tPESO INDIVIDUAL");
textBox1.Enabled = false;
button1.Enabled = false;
textBox2.Focus();

}

private void button2_Click(object sender, EventArgs e)
{
peso = double.Parse(textBox2.Text);
if (sum <>
{
sum = sum + peso;
listBox1.Items.Add("\t\t" + peso.ToString());
if (sum > lim)
{
listBox1.Items.Add("Ha exedido el limite");
listBox1.Items.Add("El peso Total es:" + sum.ToString());
}
if (sum == lim)
{
listBox1.Items.Add("Ha llegado al limite");
listBox1.Items.Add("El peso Total es:" + sum.ToString());
}
textBox2.Clear();
textBox2.Focus();
}
else
{
textBox2.Enabled = false;
button2.Enabled = false;
}
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}

private void button4_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}

Practica extra problema 3 Consola


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pesca_Consola
{
class Program
{
static void Main(string[] args)
{
int limite, peso, suma = 0;
Console.WriteLine("Introduce limite de pesca:");
limite = int.Parse(Console.ReadLine());
do
{
Console.WriteLine("\nIntroduce peso individual pescado:");
peso = int.Parse(Console.ReadLine());
suma = suma + peso;
if (suma > limite)
Console.WriteLine("Ha excedido el limite");
Console.WriteLine("Total= " + suma);
}
while (suma <>

Console.ReadKey();
}
}
}

Practica extra problema 2 visual


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Num_rom_Visual
{
public partial class Form1 : Form
{
int numero;
public Form1()
{
InitializeComponent();
numero = 0;
}

private void button1_Click(object sender, EventArgs e)
{
numero = int.Parse(textBox1.Text);
textBox1.Clear();
textBox1.Focus();
if (numero <= 10 && numero > -1)
switch (numero)
{
case 1: listBox1.Items.Add(numero + "=Su equivalente en numero romano es I");
break;
case 2: listBox1.Items.Add(numero + "=Su equivalente en numero romano es II");
break;
case 3: listBox1.Items.Add(numero + "=Su equivalente en numero romano es III");
break;
case 4: listBox1.Items.Add(numero + "=Su equivalente en numero romano es IV");
break;
case 5: listBox1.Items.Add(numero + "=Su equivalente en numero romano es V");
break;
case 6: listBox1.Items.Add(numero + "=Su equivalente en numero romano es VI");
break;
case 7: listBox1.Items.Add(numero + "=Su equivalente en numero romano es VII");
break;
case 8: listBox1.Items.Add(numero + "=Su equivalente en numero romano es VIII");
break;
case 9: listBox1.Items.Add(numero + "=Su equivalente en numero romano es IX");
break;
case 10: listBox1.Items.Add(numero + "=Su equivalente en numero romano es X");
break;
case 0: listBox1.Items.Add(numero + "=Salida programa");
textBox1.Clear();
textBox1.Enabled = false;
button1.Enabled = false;
break;
}
else
{
listBox1.Items.Add(numero + "=No introdujo numero correcto");
}
}

private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica extra problema 2 consola


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practica_ext_Num.rom
{
class Program
{
static void Main(string[] args)
{
int numero;
do
{
Console.WriteLine("Introduce un valor entero 1-10 y 0 para salir");
numero = int.Parse(Console.ReadLine());
switch (numero)
{
case 1: Console.WriteLine("Su equivalente en numero romano es I");
break;
case 2: Console.WriteLine("Su equivalente en numero romano es II");
break;
case 3: Console.WriteLine("Su equivalente en numero romano es III");
break;
case 4: Console.WriteLine("Su equivalente en numero romano es IV");
break;
case 5: Console.WriteLine("Su equivalente en numero romano es V");
break;
case 6: Console.WriteLine("Su equivalente en numero romano es VI");
break;
case 7: Console.WriteLine("Su equivalente en numero romano es VII");
break;
case 8: Console.WriteLine("Su equivalente en numero romano es VIII");
break;
case 9: Console.WriteLine("Su equivalente en numero romano es IX");
break;
case 10: Console.WriteLine("Su equivalente en numero romano es X");
break;
case 0: Console.WriteLine("Salida Programa");
break;
default: Console.WriteLine("No Introducio numero correcto");
break;
}
}
while (numero != 0);
Console.ReadKey();
}
}
}

Practica extra problema 1 visual


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace practica_extra_suma_de_nuemeros_visual
{
public partial class Form1 : Form
{
int n, suma, promedio, dato;
public Form1()
{
InitializeComponent();
n = suma = promedio = 0;
dato = 0;
label1.Text= "introduceun numero entero".ToString();
}

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("numero entero");
n = int.Parse(textBox1.Text);
listBox1.Items.Add(n.ToString());
if (n != 9999)
{
suma = suma + n;
textBox1.Clear();
textBox1.Focus();
dato++;
if (n == 9999)
{
textBox1.Clear();
textBox1.Enabled = false;
button1.Enabled = false;
}



}
else
{
textBox1.Clear();
textBox1.Enabled = false;
button1.Enabled = false;
if (n == 0)
{
label1.Text = "introduceun numero diferente a 0".ToString();
}

}
}

private void button2_Click(object sender, EventArgs e)
{
promedio = suma / dato;
listBox1.Items.Add("el promedio es "+promedio.ToString());

}

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();
}
}
}

Practica extra problema 1 consola







using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace practica_extra_sumade_numeros_enteros
{
class Program
{
static void Main(string[] args)
{
int n = 0, suma = 0, promedio = 0;
int dato = 0;
Console.WriteLine("introduce nuemero entero ");
n = int.Parse(Console.ReadLine());
while (n != 9999)
{
suma = suma + n;
dato = dato + 1;
if (n == 0)
{
Console.WriteLine("introduce numero diferente a 0");
n = int.Parse(Console.ReadLine());
suma = suma + n;
dato = dato - 1;
}
Console.WriteLine("introduce nuemero entero ");
n = int.Parse(Console.ReadLine());
}

if (n == 9999)
{
dato = dato - 1;
}
promedio = suma / dato;
Console.WriteLine("el promedio es {0}", promedio);
Console.ReadKey();
}
}
}

jueves, 12 de noviembre de 2009

Practica 7.8 Visual



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Practica_8_prob_8_W
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int N, P = 1, C;
N = int.Parse(textBox1.Text);
label2.Text = "El producto de los numeros es:";
for (C = 1; C <= N; C = C + 2)
{
P = P * C;
}
label2.Text = label2.Text + P.ToString();


}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
label2.Text = ("");
}

private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 7.7 Visual





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Practica_8_prob_8_W
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)
{
int N, P = 1, C;
N = int.Parse(textBox1.Text);
label2.Text = "El producto de los numeros es:";
for (C = 1; C <= N; C = C + 2)
{
P = P * C;
}
label2.Text = label2.Text + P.ToString();


}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
label2.Text = ("");
}

private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 7.6 Visual




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Mayor_o_Men_W
{
public partial class Form1 : Form
{
int N, Valor, May, Men, c = 1;
public Form1()
{
InitializeComponent();

listBox1.Items.Add("Valores enteros");
}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
N = int.Parse(textBox1.Text);
Valor = int.Parse(textBox2.Text);
textBox2.Focus();
textBox2.Clear();

if (c <= N)
{


listBox1.Items.Add(Valor);

if (Valor > May)
{
May = Valor;
}
if (Valor <>
{
Men = Valor;
}

c = c + 1;
}

else
{
textBox2.Clear();
textBox2.Enabled = false;
button1.Enabled = false;
}





}

private void button2_Click(object sender, EventArgs e)
{
label3.Text = "El dato mayor es:" + May.ToString();
label4.Text = "El dato menor es:" + Men.ToString();
}

private void button3_Click(object sender, EventArgs e)
{
textBox2.Clear();
textBox1.Clear();
listBox1.Items.Clear();
button1.Enabled = true;
}

private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 7.4 Visual



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Practica_8_prob_4_W
{
public partial class Form1 : Form
{
int N;
int valores;
int I = 0;
int sumapar = 0;
int sumaimpar = 0;

public Form1()
{



InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
N = int.Parse(textBox1.Text);

if (I <= N) { I = int.Parse(textBox2.Text); listBox1.Items.Add(I); if (I % 2 == 0) { sumapar += I; } if (I % 2 == 1) { sumaimpar += I; } I++; } else { button1.Enabled = false; } textBox1.Focus(); textBox2.Focus(); textBox2.Clear(); } private void button2_Click(object sender, EventArgs e) { if (sumapar > sumaimpar)
{
label5.Text = "La suma mayor es par";
}
else
{
label5.Text = "La suma mayor es impar";
}


label3.Text = "La suma de los pares es:" + sumapar.ToString();
label4.Text = "La suma de los impares es:" + sumaimpar.ToString();


}

private void button3_Click(object sender, EventArgs e)
{
label3.Text = "";
label4.Text = "";
label5.Text = "";
listBox1.Items.Clear();
textBox1.Clear();
textBox2.Clear();
button1.Enabled = true;

}

private void button4_Click(object sender, EventArgs e)
{
Close();
}

}
}

Practica 10.1 Visual



using System.Windows.Forms;
using System;
namespace Practica_10._1_Visual
{
public partial class Form1 : Form
{
double[] pendiente;
double minimo, maximo;
int i;
public Form1()
{
InitializeComponent();
pendiente = new double[] { 17.24, 25.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, 6.92 };
maximo = pendiente[0];
minimo = pendiente[0];
}

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("\tPendientes");
for (i = 0; i <>
{
listBox1.Items.Add(pendiente[i].ToString());
if (pendiente[i] > maximo)
{
maximo = pendiente[i];
}
if (pendiente[i] <>
{
minimo = pendiente[i];
}
}
listBox1.Items.Add("El valor maximo es: " + maximo);
listBox1.Items.Add("El valor minimo es: " + minimo);
}

private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 10.1 Consola


PSEUDOCODIGO
{INICIO
REAL pendiente[9] = { 17.24, 25.63, 5.94, 33.92, 3.71, 2.84, 35.93, 18.24, 6.92 };
double mayor = pendiente[0];
double menor = pendiente[0];
int i;
PRINT "Pendientes:"
for(i=0 TO 8 STEP I¿I+1 )
{
PRINT(pendiente[i]);
if(pendiente[i]>mayor)
{
mayor=pendiente[i];
}
if(pendiente[i]
{
menor=pendiente[i];
}}

PRINT "Dato Mayor: {0}",mayor
PRINT "Dato Me
nor: {0}", menor
FINAL













using System;
namespace Practica_10._1_Consola
{
class Program
{
static void Main(string[] args)
{
double[] pendiente = { 17.24, 25.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, 6.92 };
double minimo, maximo;
int i;
maximo = pendiente[0];
minimo = pendiente[0];
Console.WriteLine("Pendientes");
for (i = 0; i <> maximo)
{
maximo = pendiente[i];
}
if (pendiente[i] < minimo)
{
minimo = pendiente[i];
}
}

Console.WriteLine("\nEl valor maximo es: " + maximo);
Console.WriteLine("El valor minimo es: " + minimo);
Console.ReadKey();
}
}
}

Practica 10.2 Visual


PSEUDOCODIGO
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









using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PRACTICA_10_1_W
{
public partial class Form1 : Form
{
int[] RESISTENCIAS = { 16, 27, 39, 56, 81 };
int[] CORRIENTE = new int[5];
int[] POTENCIA = new int[5];
int TOTAL = 0;
int I;

public Form1()
{
InitializeComponent();
listBox1.Items.Add("Resistencia Corriente Potencia");
listBox1.Items.Add("_____________________________________________");

}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("El total es:" + TOTAL);

{



}
}

private void button1_Click(object sender, EventArgs e)
{
if (I <>
{
textBox1.Focus();
CORRIENTE[I] = int.Parse(textBox1.Text);
POTENCIA[I] = CORRIENTE[I] * RESISTENCIAS[I];
textBox1.Clear();
POTENCIA[I] = RESISTENCIAS[I] * CORRIENTE[I] * CORRIENTE[I];
TOTAL = TOTAL + POTENCIA[I];
listBox1.Items.Add(RESISTENCIAS[I] + "\t\t" + CORRIENTE[I] + "\t\t" + POTENCIA[I]);
I++;
}

}

private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox1.Clear();

}

private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

Practica 10.2 Consola



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PRACTICA_10_1C
{
class Program
{
static void Main(string[] args)
{
int[] RESISTENCIAS = { 16, 27, 39, 56, 81 };
int[] CORRIENTE = new int[5];
int[] POTENCIA = new int[5];
int TOTAL = 0;
int I;
for (I = 0; I <= 4; I = I + 1)
{
Console.WriteLine("Introduce corriente:", I + 1);
CORRIENTE[I] = int.Parse(Console.ReadLine());
POTENCIA[I] = RESISTENCIAS[I] * CORRIENTE[I] * CORRIENTE[I];
TOTAL = TOTAL + POTENCIA[I];

}
Console.WriteLine("RESISTENCIA CORRIENTE POTENCIA");
Console.WriteLine("_________________________________________________");
for (I = 0; I <= 4; I = I + 1)
{
Console.WriteLine("{0}\t\t\t{1}\t\t{2}", RESISTENCIAS[I], CORRIENTE[I], POTENCIA[I]);
}
Console.WriteLine("\n\nEl total es:{0}", TOTAL);
Console.ReadKey();
}
}
}

Practica 10.3 Visual



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PRACTICA_10_3_W
{
public partial class Form1 : Form
{
double[,] voltajes = new double[3, 6];
int C1, C2;
int R, C;

public Form1()
{
InitializeComponent();
C1 = C2 = 0;
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
if (R < 3)
{
if (C < 5)
{
voltajes[R, C] = double.Parse(V.Text);
listBox1.Items.Add("Voltaje[" + R.ToString() + "," + C.ToString() + "]:" + voltajes[R, C].ToString());
C++;
V.Clear();
V.Focus();
}
else
{
R++;
C = 0;
}
}


}

private void button2_Click(object sender, EventArgs e)
{
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;
}
}
}
}
MessageBox.Show("Voltajes <>= 60 : " + C2);
}

private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
V.Clear();

}

private void button4_Click(object sender, EventArgs e)
{
Close();
}

}
}

martes, 10 de noviembre de 2009

Practica 10.3 Consola

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>=60 : {1}", c1,c2);
FINAL




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double[,] voltajes = new double[3, 5];
int c1 = 0, c2 = 0;
int r,c;
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("numero de voltajes<60>
Console.WriteLine("numero de voltajes>=60 {0}",c2 );
Console.ReadKey();





}
}
}

martes, 3 de noviembre de 2009

Practica 9 Visual


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace practica_9._1windows
{
public partial class Form1 : Form
{
int[] calificacion;
int[]desviacion;
int suma,promedio,i,variansa;
public Form1()
{
InitializeComponent();
calificacion = new[] { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73 };
desviacion=new int [14];
i=suma=promedio=variansa=0;


}

private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("calificacion desviacion");
for (i = 0; i < 14; i++)
{
suma = suma + calificacion[i];
}
promedio = suma / 14;
for (i = 0; i < 14; i++)
{
desviacion[i]=calificacion[i]-promedio;
listBox1.Items.Add(calificacion[i]+" "+desviacion[i]);
}
suma = 0;
for (i = 0; i < 14; i++)
{
suma = suma + desviacion[i] * desviacion[i];
}
variansa = suma / 14;
listBox1.Items.Add("la variansa es"+variansa);

}
}
}

Practica 9 Consola



Pseudocodigo

int[ ] calificaciones = { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73 };
int[ ] desviacion = new int[14];
int suma = 0, promedio, I, variancia;
Print("\nCalificacion Desviacion");
for (I = 0; I < 14; I++)
{
suma = suma + calificaciones[I];
}
promedio = suma / 14;ss

for (I = 0; I < 14; I++)
{
desviacion[I] = calificaciones[I] - promedio;
Print (calificaciones[I] + "\t\t" + desviacion[I]);
}
suma = 0;
for (I = 0; I < 14; I++)
{
suma = suma + desviacion[I] * desviacion[I];
}
variancia = suma / 14;
Print ("La barianza es:" + variancia);

Fin.





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practica_9._1_Consola
{
class Program
{
static void Main(string[] args)
{
int [] calificaciones= {89,95,72,83,99,54,86,75,92,73,79,75,82,73};
int [] desviacion= new int [14];
int suma=0,promedio,i,variancia;
for(i=0;i<14;i++)
{
suma=suma+calificaciones[i];
}
promedio=suma/14;
for (i = 0; i <>
{
desviacion[i] = calificaciones[i] - promedio;
}
Console.WriteLine("Calificaion desviacion");
for (i = 0; i <>
{
Console.WriteLine("{0}\t{1}", calificaciones[i], desviacion[i]);
}
suma = 0;
for (i = 0; i <>
{
suma = suma + desviacion[i] * desviacion[i];
}
variancia = suma / 14;
Console.WriteLine("La variancia es: " + variancia);
Console.ReadKey();

}
}
}