Friday, October 31, 2008

EXAMEN CONSOLA, VISUAL Y DIAGRAMA




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

namespace WindowsApplication1
{
public partial class frmExamen : Form
{


int[,] Matriz;
string[] Nombres;
int R, C;
int M, N,renglon;
int mayor = 0;

public frmExamen()
{
InitializeComponent();
R = C = 0;
M = N = 0;
}

private void button1_Click(object sender, EventArgs e)
{
M = int.Parse(txtplantas.Text);
N = int.Parse(txtdias.Text);
Nombres = new string[M];
Matriz = new int[M, N + 1];
txtplantas.Enabled = false;
txtdias.Enabled = false;
button1.Enabled = false;
txtnplanta.Text = (R + 1).ToString();
textBox4.Text = (C + 1).ToString();

txtproduccion.Focus();


}

private void button2_Click(object sender, EventArgs e)
{
if (R < M && C < N)
{
Matriz[R, C] = int.Parse(txtproduccion.Text);
Nombres[R] = txtplantan.Text;
C++;
txtplantan.Enabled = false;


if (C == N)

{
C = 0;
R++;
txtplantan.Enabled = true;
txtplantan.Clear();
}
if (R != M)
{
txtnplanta.Text = (R + 1).ToString();
textBox4.Text = (C + 1).ToString();
txtproduccion.Clear();

txtproduccion.Focus();

}
else
{
txtnplanta.Enabled = false;
textBox4.Enabled = false;
txtproduccion.Enabled = false;
txtplantan.Enabled = false;
MessageBox.Show("Todos los datos fueron introducidos");
}
}
}

private void button3_Click(object sender, EventArgs e)
{
int Suma = 0;
lstagregar.Items.Add("No.Planta Planta Produccion semanal");
for (R = 0; R < M; R++)
{
Suma = 0;

for (C = 0; C < N; C++)
{
Suma += Matriz[R, C];
}
Matriz[R, C] = Suma;
}
for (R = 0; R < M; R++)
{
lstagregar.Items.Add((R + 1).ToString() + " " + Nombres[R] + " " + Matriz[R, N].ToString());

}
for (R = 0; R < M; R++)
{
Suma = Matriz[R, N];
if (Suma > mayor)
{
mayor = Matriz[R, N];
renglon = R;
}
}
lblNumplant.Text=" El numero de Planta con mayor produccion es:"+ (renglon + 1);
lblNombplant.Text="Nombre de la Planta:" + Nombres[renglon];
lblMayorprod.Text="Total de la produccion es:"+ mayor;
}

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


}
}







DIAGRAMA DE FLUJO DE EXAMEN








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

namespace examen
{
class Program
{
static void Main(string[] args)
{

string[] nombres = new string[8];
int[,] produccion = new int[8, 7];
int suma=0;
int mayor = 0;
int mayor_planta=0;
Console.WriteLine("Examen");


for (int i = 0; i < 8; i++)
{


Console.Write("Captura nombre de la planta {0} ",i+1);
nombres[i] = Console.ReadLine();
}

for ( int j=0; j<8;j++){
Console.Clear();
Console.WriteLine("Planta {0}", nombres[j]);
for (int a = 0; a < 7; a++)
{


Console.Write("Captura la produccion dia {0} :", a + 1);
produccion[j, a] = System.Int32.Parse(Console.ReadLine());
}
Console.Clear();

}
//for (int i = 0; i < 8; i++)
//{
// Console.Write("{0}", nombres[i]);
//}
for (int j = 0; j < 8; j++)
{

suma = 0;
for (int a = 0; a < 7; a++)
{

Console.WriteLine("dia{0} produccion {1}", a + 1, produccion[j, a]);
suma = suma + produccion[j, a];
}

Console.WriteLine("\nProduccion total de planta {0} : {1} ", nombres[j], suma);
produccion[j,6]=suma;

}
Console.ReadLine();
Console.Clear();


mayor=0;
for (int j = 0; j < 8; j++)
{
if( produccion[j,6] < mayor){
mayor = produccion[j, 6];
mayor_planta=j;
}
}

Console.WriteLine("La planta con mayor produccion es {0}", nombres[mayor_planta]);
Console.ReadLine();
Console.WriteLine("Presione Intro para salir");

}
}
}

EXAMEN CONSOLA

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

namespace examen
{
class Program
{
static void Main(string[] args)
{

string[] nombres = new string[8];
int[,] produccion = new int[8, 7];
int suma=0;
int mayor = 0;
int mayor_planta=0;
Console.WriteLine("Examen");


for (int i = 0; i < 8; i++)
{


Console.Write("Captura nombre de la planta {0} ",i+1);
nombres[i] = Console.ReadLine();
}

for ( int j=0; j<8;j++){
Console.Clear();
Console.WriteLine("Planta {0}", nombres[j]);
for (int a = 0; a < 7; a++)
{


Console.Write("Captura la produccion dia {0} :", a + 1);
produccion[j, a] = System.Int32.Parse(Console.ReadLine());
}
Console.Clear();

}
//for (int i = 0; i < 8; i++)
//{
// Console.Write("{0}", nombres[i]);
//}
for (int j = 0; j < 8; j++)
{

suma = 0;
for (int a = 0; a < 7; a++)
{

Console.WriteLine("dia{0} produccion {1}", a + 1, produccion[j, a]);
suma = suma + produccion[j, a];
}

Console.WriteLine("\nProduccion total de planta {0} : {1} ", nombres[j], suma);
produccion[j,6]=suma;

}
Console.ReadLine();
Console.Clear();


mayor=0;
for (int j = 0; j < 8; j++)
{
if( produccion[j,6] < mayor){
mayor = produccion[j, 6];
mayor_planta=j;
}
}

Console.WriteLine("La planta con mayor produccion es {0}", nombres[mayor_planta]);
Console.ReadLine();
Console.WriteLine("Presione Intro para salir");

}
}
}

Thursday, October 30, 2008

Practica 5 Visual





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

namespace Practica5_visual
{
public partial class frmPractica5visual : Form
{
public frmPractica5visual()
{
InitializeComponent();
}
int NumA = 0, NumC = 0, R = 0, C = 0;
int Suma = 0,b=0;
string[] Nombres;
int[,] Calificaciones;
double[] Promedio;

private void cmdCapturar_Click(object sender, EventArgs e)
{





if (R < NumA)
{
if (b == 0)
{
Nombres[R] = txtNombre.Text;
lstNombres.Items.Add(Nombres[R].ToString());
txtNombre.Enabled = false;
b = 1;
}
if (C < NumC)
{
txtCalificaciones.Enabled = true;
Calificaciones[R, C] = System.Int16.Parse(txtCalificaciones.Text);
txtNota.Text=txtNota.Text.ToString()+Calificaciones[R,C].ToString()+"\t";
txtCalificaciones.Clear();
txtCalificaciones.Focus();
C++;

if (C == NumC)
{
txtNota.Text = txtNota.Text + "\r\n";
txtNombre.Enabled = true;
txtNombre.Clear();
txtNombre.Focus();
R++;
b = 0;
C = 0;
}

}

}



if (R == NumA)
{
txtNombre.Enabled = false;
txtCalificaciones.Enabled = false;
for (R = 0; R < NumA; R++)
{

Suma = 0;
for (C = 0; C < NumC; C++)
{
Suma = Suma + Calificaciones[R, C];

}
Promedio[R] = Suma / NumC;
lstPromedio.Items.Add(Promedio[R].ToString());
}

}

}





private void cmdLimpiar_Click(object sender, EventArgs e)
{
txtCalificaciones.Clear();
txtNombre.Clear();
txtNumA.Enabled = true;
txtNumC.Enabled = true;
lstNombres.Items.Clear();
lstPromedio.Items.Clear();
txtNota.Clear();
txtNumA.Clear();
txtNumC.Clear();
txtNumA.Focus();
}

private void cmdCap_Click(object sender, EventArgs e)
{
NumA = System.Int16.Parse(txtNumA.Text);
NumC = System.Int16.Parse(txtNumC.Text);
txtNumA.Enabled = false;
txtNumC.Enabled = false;

Nombres = new string[NumA];
Calificaciones = new int[NumA, NumC];
Promedio = new double[NumA];
}

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

private void frmPractica5_Load(object sender, EventArgs e)
{

}




}
}

Practica 8 consola

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

namespace Aplicacion_consola_tres_dimensionaes
{
class Program
{
static void Main(string[] args)
{
double[, ,] compañía;
int numS, noDep, dias;
Console.Write("Introduce el número de sucursales: ");
numS = int.Parse(Console.ReadLine());
Console.Write("Introduce el número de departamentos: ");
noDep = int.Parse(Console.ReadLine());
Console.Write("Introduce el número de dias : ");
dias = int.Parse(Console.ReadLine());
compañía = new double[numS, noDep, dias];
int p, s, t;
for (p = 0; p < numS; p++)
{
Console.WriteLine("Sucursal {0}: ", p + 1);
for (s = 0; s < noDep; s++)
{
Console.WriteLine("Departamento {0}: ", s + 1);
for (t = 0; t < dias; t++)
{
Console.Write(" dia {0}: ", t + 1);
compañía[p, s, t] = double.Parse(Console.ReadLine());
}
}
}
double suma = 0.0;
for (p = 0; p < numS; p++)
{
suma = 0.0;
for (s = 0; s < noDep; s++)
{
suma = 0.0;
for (t = 0; t < dias; t++)
{
suma += compañía[p, s, t];

}
Console.WriteLine("venta total por sucursal:{0}", suma);
}
Console.WriteLine(" No de Sucursal: {0} ", p + 1);
Console.WriteLine(" Venta Total es : {0} ", suma);
}

Console.ReadLine();

}
}
}

diagrama de flujo de practica 9

diagrama de flujo de practica 4

diagrama de flujo de practica 1

Practica 9 consola

Programa que capturas el numero de grupos, alumnos por cada grupo y calificaciones por alumno....para al ultimo sacar el promedio de cada alumno de cada grupo.



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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int ng=0,nalu=0,mat=0;
int suma=0;
double promedio=0;



Console.Write("Practica 9");
Console.Write("\n\n\nCaptura numero de grupos: ");
ng = System.Int32.Parse(Console.ReadLine());
Console.Write("\nCaptura numero de alumnos: ");
nalu = System.Int32.Parse(Console.ReadLine());
Console.Write("\nCaptura numero de materias por alumnos: ");
mat = System.Int32.Parse(Console.ReadLine());

int[, ,] kodex = new int[ng, nalu, mat];


for(int g=0; g < ng ; g++)
{
for(int a=0; a< nalu; a++)
{
Console.Clear();
Console.WriteLine("Calificaciones de los alumnos del grupo {0}", g + 1);
for(int m=0;m < mat;m++)
{


Console.Write("\nintroduce calificacion {0} de alumno {1}: ", m+1,a+1);
kodex[g, a, m] = System.Int16.Parse(Console.ReadLine());

}
}
}

for (int g=0; g < ng;g++){
Console.WriteLine("\nPromedios de los alumnos del grupo {0}", g + 1);
for(int a=0;a < nalu;a++){


suma = 0;
for(int m=0;m < mat;m++){

suma=suma+kodex[g,a,m];
}

promedio = suma / mat;

Console.WriteLine("promedio de alumno {0}: {1} ", a + 1, promedio);
}
}
Console.Write("\nPRESIONE INTRO PARA SALIR");
Console.ReadLine();


}
}
}

Diagrama de flujo de practica 6

Diagrama de flujo de practica 8

Wednesday, October 29, 2008

Practica 7 Consola

Programa que capturas el numero de estaciones cualesquieras y sus meses, capturando el responsable de cada estacion y su produccion, por ultimo desplegara la produccion de cada estacion y cual es la mas productiva..






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

namespace Aplicacion_Consola_Estaciones_de_trabajo
{

class ArregloUnidimensional
{
object[] lista;
public ArregloUnidimensional(int n)
{
lista = new object[n];
}
public void asignarDato(int indice, object dato)
{
lista[indice] = dato;
}
public object obtenerDato(int indice)
{
return lista[indice];
}
public object[] Lista
{
get { return lista; }
set { lista = value; }
}
}

class ArregloBidimensional
{
object[,] Matriz;

public ArregloBidimensional(int M, int N)
{
Matriz = new object[M, N];

}
public void asignarDato(int reng, int col, object dato)
{
Matriz[reng, col] = dato;
}
public object obtenerDato(int reng, int col)
{
return Matriz[reng, col];
}
public object[,] matriz
{
get { return Matriz; }
set { Matriz = value; }
}

}



class Program
{
static void Main(string[] args)
{
object datoNombre;
int suma = 0;
Console.Write("Introduce el numero de estaciones : ");
int num = int.Parse(Console.ReadLine());
Console.Write("introduce el numero de meses a evaluar: ");
int meses = int.Parse(Console.ReadLine());
ArregloBidimensional B = new ArregloBidimensional (num, meses + 1);
ArregloUnidimensional nom = new ArregloUnidimensional (num);
int r, c, datoProd = 0;
for (r = 0; r < num; r++)
{
Console.Write("Nombre del responsable de la estacion {0}: ", r + 1);
datoNombre = Console.ReadLine();
nom.asignarDato(r, datoNombre);
suma = 0;
for (c = 0; c < meses; c++)
{
Console.Write("Produccion del mes {0} :", c + 1);
datoProd = int.Parse(Console.ReadLine());
B.asignarDato(r, c, datoProd);
suma = suma + datoProd;
}
B.asignarDato(r, c, suma);
}
int mayor = 0;
int renglon = 0;
for (r = 0; r < num; r++)
{
suma = (int)B.obtenerDato(r, meses);
if (suma > mayor)
{
mayor = (int)B.obtenerDato(r, meses);
renglon = r;
}
}
Console.WriteLine("\n\nEl numero de estacion con mayor produccion es {0}", renglon + 1);
Console.WriteLine("Nombre del responsable {0} ", nom.obtenerDato(renglon));
Console.WriteLine("Total de la produccion es {0}", mayor);

for (r = 0; r < num; r++)
{
Console.WriteLine("\n\nNo de estacion {0}", r + 1);
Console.WriteLine("Responsable {0}", nom.obtenerDato(r));
Console.WriteLine("Total de la produccion :{0} ", B.obtenerDato(r, meses));

}
Console.ReadLine();

}
}
}

Practica 7 Visual




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

namespace WindowsApplication1
{
public partial class frmPractica7 : Form
{


int[,] Matriz;
string[] Nombres;
int R, C;
int M, N;

public frmPractica7()
{
InitializeComponent();
R = C = 0;
M = N = 0;
}

private void button1_Click(object sender, EventArgs e)
{
M = int.Parse(txtestaciones.Text);
N = int.Parse(txtnmeses.Text);
Nombres = new string[M];
Matriz = new int[M, N + 1];
txtestaciones.Enabled = false;
txtnmeses.Enabled = false;
cmdaceptar.Enabled = false;
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();

txtproduccion.Focus();


}

private void button2_Click(object sender, EventArgs e)
{
if (R < M && C < N)
{
Matriz[R, C] = int.Parse(txtproduccion.Text);
Nombres[R] = txtresponsable.Text;
C++;
txtresponsable.Enabled = false;


if (C == N)

{
C = 0;
R++;
txtresponsable.Enabled = true;
txtresponsable.Clear();
}
if (R != M)
{
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();
txtproduccion.Clear();

txtproduccion.Focus();

}
else
{
txtnestacion.Enabled = false;
txtnumeromeses.Enabled = false;
txtproduccion.Enabled = false;
txtresponsable.Enabled = false;
MessageBox.Show("Todos los datos fueron introducidos");
}
}
}

private void button3_Click(object sender, EventArgs e)
{
int Suma = 0;
lstagregar.Items.Add("No. Estacion Responsable Produccion");
for (R = 0; R < M; R++)
{
Suma = 0;

for (C = 0; C < N; C++)
{
Suma += Matriz[R, C];
}
Matriz[R, C] = Suma;
}
for (R = 0; R < M; R++)
{
lstagregar.Items.Add((R + 1).ToString() + " " + Nombres[R] + " " + Matriz[R, N].ToString());

}
}

private void frmPractica7_Load(object sender, EventArgs e)
{

}




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

}
}

Diagrama de flujo de practica 7

Diagrama de flujo de practica 5

Practica 6 visual



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

namespace Ejercicio_47
{
public partial class frmEjercicio47 : Form
{
public frmEjercicio47()
{
InitializeComponent();
}
//Declaracion de variables globales y arreglo
int[,] num = new int[4, 5];
int[] ordenar = new int[20];
int ren = 0;
int col = 0;
int p, i, m, r, c, j, k,me;
private void cmdtabla_Click(object sender, EventArgs e)
{

cmdnum.Enabled = true;
cmdtabla.Enabled = false;

//creacion de tabla aleatoria
Random aleatorio = new Random();

for (ren = 0; ren < 4; ren++)
{
for (col = 0; col < 5; col++)
{
num[ren, col] = aleatorio.Next(50);

txttabla.Text = txttabla.Text + num[ren, col] + "\t";
}
txttabla.Text = txttabla.Text + "\r\n";
}

}

private void cmdnum_Click(object sender, EventArgs e)
{
txttabla.Clear();
lblDespliegue.Visible = true;

for (p = 1; p <= 20; p++)
{
me = num[0, 0];
r = 0;
c = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
if (num[i, j] < me)
{
me = num[i, j];
r = i;
c = j;
}
}
}
ordenar[k] = me;
num[r, c] = 9999;
k++;

}

for (k = 0; k < 20; k++)
{
txttabla.Text = txttabla.Text + ordenar[k].ToString() + ", ";
}

}

private void cmdLimpiar_Click(object sender, EventArgs e)
{
cmdtabla.Enabled = true;
cmdnum.Enabled = false;
lbltabla.Visible = true;
lblDespliegue.Visible = false;
txttabla.Text = "";
txttabla.Clear();

}

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

private void lblDespliegue_Click(object sender, EventArgs e)
{

}

private void txttabla_TextChanged(object sender, EventArgs e)
{

}
}
}

Practica 3 Visual





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

namespace WindowsApplication1
{
public partial class frmPrograma3 : Form
{
int Ceconomica = 10;
int i = 0;
int I = 10;
int[] avion = new int[30];
int Primerac = 0;
public frmPrograma3()
{
InitializeComponent();
}

private void cmdAvion_Click_1(object sender, EventArgs e)
{
if (PrimeraClase.Checked)
{
if (Primerac < 10)
{

label2.ForeColor = System.Drawing.Color.Green;
label2.Text="Asiento # "+ (i+ 1)+ " Primera Clase";

avion[Primerac] = 1;
Primerac++;
i++;

}


else
{
MessageBox.Show("Primera Clase Llena \nSi decea seleccione la opcion de Clase economica");
PrimeraClase.Enabled = false;
PrimeraClase.Checked = false;

}

}


if (Claseconomica.Checked)
{

if (Ceconomica < 30)
{

label3.ForeColor = System.Drawing.Color.Green;
label3.Text="Asiento # " + (I + 1) + " Clase Economica";
avion[Ceconomica] = 1;
Ceconomica++;
I++;


}

else
{


MessageBox.Show("Clase Economica Llena \n\nSi decea seleccione la opcion de Primera clase");
Claseconomica.Enabled = false;
Claseconomica.Checked = false;

}
}
}

private void frmPrograma3_Load(object sender, EventArgs e)
{

}

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

}

}

Wednesday, October 22, 2008

Practica 6 consola

Programa en C# para seleccionar los valores en un arreglo 4 por 5 en números enteros en orden ascendente y que almacene los valores seleccionados en un arreglo unidimensional llamado ordenar.


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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[,] m = new int[4, 5];
int[] ordenar = new int[20];
int i, j, r, c, p, me, k = 0;
Console.WriteLine("introduce los datos");
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{

Console.Write("m[{0},{1}]:", i, j);
m[i, j] = int.Parse(Console.ReadLine());
}
}
for (p = 1; p <= 20; p++)
{
me = m[0, 0];
r = 0;
c = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
if (m[i, j] < me)
{
me = m[i, j];
r = i;
c = j;
}
}
}
ordenar[k] = me;
m[r, c] = 9999;
k++;
}

Console.WriteLine("elementos ordenados de la matriz ordenada");
for (k=0;k<20;k++)
{
Console.Write("{0,4}", ordenar[k]);
}
Console.ReadLine();
}



}
}

Thursday, October 16, 2008

Practica 5 Consola

Escribir un programa interactivo en C# que acepte como entrada cada nombre de estudiante y sus calificaciones, determinar la nota media de cada estudiante y escribir a continuación el nombre del estudiante, las notas de los exámenes y la media calculada.
Considere lo más general el problema, el usuario debe determinar el número de alumnos y el número de calificaciones que registra.



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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, m, r, c;
double suma = 0;
string[] nombres;
double[,] notas;
Console.WriteLine("\nPrograma que indicas cuantos alumnos vas a introducir y sus calificaciones ");

Console.Write("\nintroduce el numero de alumnos registrados: ");
n = int.Parse(Console.ReadLine());

Console.Write("Introduce el numero de calificaciones a registrar por alumnnos: ");
m = int.Parse(Console.ReadLine());

nombres = new string[n];
notas = new double[n, m];
Console.WriteLine("Introduce los siguientes datos");

for (r = 0; r < n; r++)
{
Console.WriteLine("Nombre Alumno {0}", r + 1);
nombres[r] = Console.ReadLine();

for (c = 0; c < m; c++)
{
Console.WriteLine("Calificacion{0}", c + 1);
notas[r, c] = double.Parse(Console.ReadLine());
}
}
Console.WriteLine("Nombre Alumno Calificaciones Promedio");
;

for (r = 0; r < n; r++)
{
Console.Write("{0}", nombres[r]);
suma = 0.0;
for (c = 0; c < m; c++)
{
Console.Write("\t{0}", notas[r, c]);
suma = suma + notas[r, c];
}
Console.WriteLine("\t\t\t {0}", suma / m);
}
Console.WriteLine("dar intro para salir");
Console.ReadLine();
}
}
}

Practica 4 Visual





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

namespace Prcatica4a_Visual
{

public partial class frmPractica4a : Form
{
rectangulo rect;
circulo circ;
Triangulo trian;
public frmPractica4a()
{

rect = new rectangulo();
circ = new circulo();
trian = new Triangulo();
InitializeComponent();
txtanchorect.Text = "0";
txtlargorect.Text = "0";
}

private void cmdcalculo_Click(object sender, EventArgs e)
{

int opc=0;
opc = System.Int32.Parse(txtopcion.Text);


if (opc == 1)
{
txtlargorect.Visible = true;
txtanchorect.Visible = true;
lbllargo.Visible = true;
lbl12.Visible = true;
lblbase.Visible = true;
lblradio.Visible = true;
lblaltura.Visible = true;
txtanchorect.Focus();
rect.Ancho= Double.Parse(txtanchorect.Text);
rect.Largo = Double.Parse(txtlargorect.Text);


lblareas.Text = "AREA = " +rect.area().ToString();
lblperimetros.Text = "PERIMETRO= " + rect.perimetro().ToString();

}
else if (opc == 2)
{

txtanchorect.Visible = true;
txtlargorect.Visible = true;
txtlargorect.Focus();
lblbase.Visible = true;
lbllargo.Visible = true;
trian.altura = Double.Parse(txtanchorect.Text);
trian.basetrieangulo = Double.Parse(txtlargorect.Text);
lblareas.Text = "El area del triangulo es: " + trian.areatriangulo().ToString();
}
else if (opc == 3)
{

txtlargorect.Focus();
lblradio.Visible = true;
txtlargorect.Visible = true;
circ.Radio = Double.Parse(txtlargorect.Text);
lblareas.Text = "El area del Circulo es: " + circ.Area().ToString();
lblperimetros.Text = "La circuferencia es: " + circ.Circunferencia().ToString();
}
else
{
MessageBox.Show("Tu opcion no esta en el menu....elige bien");
txtopcion.Focus();
txtopcion.Clear();

}

}

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





}

Monday, October 13, 2008

Practica 1 Visual





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

namespace Practica_1
// DIAZ CABALLERO JOSE SALVADOR
//PRACTICA 1
//PROGRAMA QUE CAPTURAS N NUMEROS Y SACAS EL MAYOR, MENOR Y DIFERENCIA

{
public partial class frmPractica1 : Form
{
public frmPractica1()
{
InitializeComponent();
}
// Declaracion de variables Globales
int N,mayor = 0, menor = 999, Dif;

int i = 0;
private void cmdCa_Click(object sender, EventArgs e)
{

N = System.Int16.Parse(txtrep.Text);
txtrep.Focus();
cmdCa.Visible = false;
cmdMayor.Visible = true;


}
private void cmdMayor_Click(object sender, EventArgs e)
{

// Asignacion de valores a las variables

lstCap.Items.Add(System.Int32.Parse(txtCap.Text));
txtCap.Focus();
txtCap.Clear();
i++;
if (i == N)
{
txtCap.Visible = false;
label1.Visible = false;
cmdMayor.Visible = false;
txtrep.Focus();
}
}

private void cmdmenor_Click(object sender, EventArgs e)
{
int emax;

for (i = 0; i < N; i++)
{
emax = System.Int16.Parse(lstCap.Items[i].ToString());
// El numero mayor
if (emax > mayor)

mayor = emax;


lblMayor.Text = "El mayor es: " + mayor.ToString();

// El numero menor
if (emax < menor)

menor = emax;

lblMenor.Text = "El menor es: " + menor.ToString();

// La diferiencia entre el mayor y el menor
Dif = mayor - menor;

lbldes.Text = "La diferencia es: " + Dif.ToString();

}
}

private void lstCap_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void cmdlimpiar_Click(object sender, EventArgs e)
{
txtrep.Focus();
txtCap.Clear();
lstCap.Items.Clear();
txtCap.Visible = true;
label1.Visible = true;
cmdMayor.Visible = true;
lblMayor.Text = "";
lblMenor.Text = "";
lbldes.Text = "";
cmdCa.Visible = true;
txtrep.Clear();


}

private void frmPractica1_Load(object sender, EventArgs e)
{

}

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






}
}

Practica 4 Consola

Hacer un programa en C# para crear una clase de rectángulo,clase círculo, clase de triángulo para calcular el área y perímetro de cada figura.

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

namespace Practica4a
{
class Rectangulo
{
double largo, ancho;
public Rectangulo(double w, double h)
{
ancho = w;
largo = h;
}
public Rectangulo()
{
ancho = 1;
largo = 1;
}
public double area()
{
return largo * ancho;
}
public double perimetro()
{
return 2 * (largo + ancho);
}
public double Ancho
{
get { return ancho; }
set { ancho = value; }
}
public double Largo
{
get { return largo; }
set { largo = value; }
}
}
class Triangulo
{

double Altura;
double Base;

public Triangulo(double h, double b)
{
Altura = h;
Base = b;
}
public Triangulo()
{
Altura = 0;
Base = 0;
}
public double areatriangulo()
{
return (Base * Altura) / 2;
}
public double altura
{
get { return Altura; }
set { Altura = value; }
}
public double basetrieangulo
{
get { return Base; }
set { Base = value; }
}
}
class circulo
{
double radio;

public circulo(double r)
{
radio = r;
}
public circulo()
{
radio = 1;
}
public double Area()
{
return Math.PI * Math.Pow(radio, 2);
}
public double Circunferencia()
{
return Math.PI * radio * 2;
}
public double Radio
{
get { return radio; }
set { radio = value; }
}
}






class Program
{
static void Main(string[] args)
{

int opcion = 0;
char opc;
do{
Console.WriteLine("\nPROGRAMA QUE CALCULA AREA DE CIERTAS FIGURAS GEOMETRICAS");
Console.WriteLine("\nELIJA LA OPCION QUE DESEA HACER");

Console.WriteLine("\nSI DESEA SACAR AREA Y PERIMETRO DE RECTANGULO TECLEE 1");
Console.WriteLine("\nSI DESEA SACAR AREA Y DE UN TRIANGULO TECLEE 2");
Console.WriteLine("\nSI DESEA SACAR AREA Y CIRCUNFERENCIA DE UN CIRCULO TECLEE 3");
Console.Write("\nQue opcion elije:");
opcion = int.Parse(Console.ReadLine());


if (opcion == 1)
{
Console.Clear();
Console.WriteLine("CALCULO DEL AREA Y PERIMETRO DE UN RECTANGULO");
double L1, A1;
Console.WriteLine("\n\nDatos de un rectangulo ");
Console.Write("\n\nIntroduce el largo de un rectangulo : ");
L1 = double.Parse(Console.ReadLine());
Console.Write("Introduce el ancho de un rectangulo : ");
A1 = double.Parse(Console.ReadLine());
Rectangulo tresRect = new Rectangulo(A1, L1);

Console.WriteLine("\n ancho={0},largo={1} ", tresRect.Ancho, tresRect.Largo);
Console.WriteLine("\nArea={0} , perimetro= {1} ", tresRect.area(), tresRect.perimetro());


Console.ReadLine();


}
else if (opcion == 2)
{
Console.Clear();
Console.WriteLine("CALCULO DEL AREA DE UN TRIANGULO");
double base1, altura1;
Console.WriteLine("\n\nDatos del Triangulo ");
Console.Write("\n\nIntroduce la base de un Triangulo : ");
base1 = double.Parse(Console.ReadLine());
Console.Write("\n\nIntroduce la altura del Triangulo : ");
altura1 = double.Parse(Console.ReadLine());
Triangulo untriangulo = new Triangulo(altura1, base1);
Console.WriteLine("\nbase={0}, altura={1}", untriangulo.basetrieangulo, untriangulo.altura);
Console.WriteLine("\n Area={0} ", untriangulo.areatriangulo());

Console.ReadLine();
}
else if (opcion == 3)
{
Console.Clear();
Console.WriteLine("CALCULO DEL AREA Y CIRCUFERENCIA DE UN CIRCULO");
double Radio1;
Console.WriteLine("\n\nDatos del Circulo ");
Console.Write("\n\nIntroduce el radio del Circulo : ");
Radio1 = double.Parse(Console.ReadLine());
circulo uncirculo = new circulo(Radio1);
Console.WriteLine("\n Radio={0}", uncirculo.Radio);
Console.WriteLine("\n Area={0}, circuferencia={1}", uncirculo.Area(), uncirculo.Circunferencia());

Console.ReadLine();

}
else
{
Console.Clear();

Console.WriteLine("OPCION INCORRECTA.");
}

Console.WriteLine("Si desea continuar presione 's'");
opc = char.Parse(Console.ReadLine());

Console.Clear();



}


while (opc == 's' || opc == 'S') ;

}
}
}

Practica 3 diagrama de flujo

Practica 3 Consola

Una pequeña aerolínea acaba de comprar una computadora para su nuevo sistema automático de reservaciones. A usted se le ha pedido que programe el nuevo sistema. Usted debe escribir un programa que asigne los asientos, en cada vuelo, del único avión de la aerolínea (capacidad : 30 asientos).
su programa debe desplegar el siguiente menú de alternativas:
digite 1 para primera clase
digite 2 para económico

Si la persona digita 1, su programa debe asignar un asiento en la sección de primera clase (asientos del 1 al 10). Si la persona digita 2, su programa debe asignar un asiento en la sección económica (asientos 11 al 30). Su programa debe imprimir un pase de abordar que indique el número de asiento de la persona y si está en la sección de primera clase o en la sección económica del avión.
Utilice un arreglo con un solo subíndice para presentar los asientos del avión. Inicialice en cero todos los elementos del arreglo para indicar que todos los asientos estan vacíos.Mientras se asigna cada asiento, el valor de los elemntos correspondientes del arreglo se establece en 1, para indicar que el asiento ya no está disponible.
Por supuesto, su programa nunca debe asignar un asiento que ya está asignado. Cuando la sección de primera clase esta llena, su programa debe preguntar a la persona que se le coloque en la sección económica ( y viceversa).
Si acepta, entonces haga la asignación apropiada del asiento. Si no acepta, entonces despliegue el mensaje "el siguiente vuelo parte en tres horas".


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

namespace practica3
{
class arreglo
{
int[] datos;
int i, cPrimera, cEconomico;
public arreglo(int n)
{
datos = new int[n];
for (i = 0; i < 30; i++)
{
datos[i] = 0;
}
i = cPrimera = 0;
cEconomico = 10;
}
public void EstablecerDato(int j)
{
datos[j] = 1;
}
public int obtnerDato(int j)
{
return datos[j];
}
public int[] Datos
{
get { return datos; }
set { datos = value; }
}
public int I
{
get { return i; }
set { i = value; }
}
public int Cprimera
{
get { return cPrimera; }
set { cPrimera = value; }
}
public int Ceconomico
{
get { return cEconomico; }
set { cEconomico = value; }
}
}
class Program
{
public static void Main(string[] args)
{
int opcion;
char opc;
arreglo avion = new arreglo(30);
do
{
Console.Clear();
Console.WriteLine("\nBIENVENIDOS A AEROLINEAS VIUX ");
Console.WriteLine("\n CONTAMOS CON DOS TIPOS DE CLASES Y SON LAS SIGUIENTES....");


Console.WriteLine("\nPor favor, digite 1 para Premier ");
Console.WriteLine("\nPor favor digite 2 para normal");
Console.Write("\nque opcion desea ");
opcion = int.Parse(Console.ReadLine());

if (opcion == 1)
{
if (avion.Cprimera < 9)
{
avion.EstablecerDato(avion.Cprimera);
Console.WriteLine("\nNo de asiento {0}", avion.Cprimera + 1);
Console.WriteLine("pase de abordar clase premier");
avion.Cprimera++;
}
else
{
Console.WriteLine("Primera clase no tiene asientos disponibles");
Console.WriteLine("Desea en clase para pobres (s/n): ");
opc = char.Parse(Console.ReadLine());
if (opc == 's' || opc == 'S')
{
if (avion.Ceconomico < 30)
{
avion.EstablecerDato(avion.Ceconomico);
Console.WriteLine("\nNo de asiento {0}", avion.Ceconomico + 1);
Console.WriteLine("\npase de abordar clase normal");
avion.Ceconomico++;
}
}
else
{ Console.WriteLine("el siguiente vuelo parte en tres horas"); }
}
}
else
{
if (opcion == 2)
{
if (avion.Ceconomico < 29)
{
avion.EstablecerDato(avion.Ceconomico);
Console.WriteLine("No de asiento: {0} ", avion.Ceconomico + 1);
Console.WriteLine("pase de abordar de clase economica");
avion.Ceconomico++;
}
else
{
Console.WriteLine("Clase Economica no tiene asientos disponible ");
Console.WriteLine("desea en Primera clase (s/n) : ");
opc = char.Parse(Console.ReadLine());
if (opc == 's' || opc == 'S')
{
if (avion.Cprimera < 9)
{
avion.EstablecerDato(avion.Cprimera);
Console.WriteLine("No de asiento : {0} ", avion.Cprimera + 1);
Console.WriteLine("pase de abordar Primera clase");
avion.Cprimera++;
}
}
else
{
Console.WriteLine("el siguiente vuelo parte en tres horas");
}
}
}

else
{
Console.WriteLine("Presiono opcion equívocada");
}
}
Console.Write("deseas continuar (s/n) : ");
opc = char.Parse(Console.ReadLine());
}
while (opc == 'S' || opc == 's');


}
}
}