viernes, 13 de marzo de 2009

Manipulacion de clases (consola)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Class_rectangulo
{
double ancho;
double largo;
public Class_rectangulo()
{
ancho = 0;
largo = 0;
}
public Class_rectangulo(double w, double h)
{
ancho = w;
largo = h;
}
public double area()
{
return ancho * largo;
}
public double perimetro()
{
return 2 * (largo + ancho);
}
public void asignarlargo(double h)
{
largo = h;
}
public void asignarancho(double w)
{
ancho = w;
}
public double obtenerlargo()
{
return largo;
}
public double obtenerancho()
{
return ancho;
}
}
}


sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Circulo
{
double radio;
public Circulo()
{
radio = 0;
}
public Circulo (double r)
{
radio = r;
}
public double area()
{
return Math.PI * Math.Pow(radio, 2);
}
public double perimetro()
{
return 2 * Math.PI + radio;
}
public void asignarradio(double r)
{
radio = r;
}
public double obtenerradio ()
{
return radio;
}
}
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Triangulo
{
double lado1, lado2, lado3;
public Triangulo()
{
lado1 = 0; lado2 = 0; lado3 = 0;
}
public Triangulo(double l1, double l2, double l3)
{
lado1 = l1; lado2 = l2; lado3 = l3;
}
public double area()
{
return Math.Sqrt(((lado1 + lado2 + lado3) / 2) * (((lado1 + lado2 + lado3) / 2) - lado1) * (((lado1 + lado2 + lado3) / 2) - lado2) * (((lado1 + lado2 + lado3) / 2) - lado3));
}
public double perimetro()
{
return lado1 + lado2 + lado3;
}
public void asignarlado1(double l1)
{
lado1 = l1;
}
public void asignarlado2(double l2)
{
lado2 = l2;
}
public void asignarlado3(double l3)
{
lado3 = l3;
}
public double obtenerlado1()
{
return lado1;
}
public double asignarlado2()
{
return lado2;
}
public double asignarlado3()
{
return lado3;
}
}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("RECTANGULO:");
Console.ForegroundColor = ConsoleColor.White;
Class_rectangulo r1 = new Class_rectangulo();
double l, a;
Console.Write("introduce largo:");
l = double.Parse(Console.ReadLine());
Console.Write("introduce ancho:");
a = double.Parse(Console.ReadLine());
r1.asignarlargo(l);
r1.asignarancho(a);
Console.WriteLine("area={0}", r1.area());
Console.WriteLine("perimetro{0}", r1.perimetro());
Console.ReadKey();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("CIRCULO R=10");
Console.ForegroundColor = ConsoleColor.White;
Circulo c1 = new Circulo(10);
Console.WriteLine("area= {0}", c1.area());
Console.WriteLine("perimetro= {0}", c1.perimetro());
Console.ReadKey();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("CIRCULO ");
Console.ForegroundColor = ConsoleColor.White;
Circulo c2 = new Circulo();
double r;
Console.Write("introduce el radio:");
r = double.Parse(Console.ReadLine());
c2.asignarradio(r);
Console.WriteLine("area= {0}", c2.area());
Console.WriteLine("perimetro= {0}", c2.perimetro());
Console.ReadKey();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("TRIANGULO:");
Console.ForegroundColor = ConsoleColor.White;
Triangulo t1 = new Triangulo();
double l1, l2, l3;
Console.Write("introduce lado 1:");
l1 = double.Parse(Console.ReadLine());
Console.Write("introduce lado 2:");
l2 = double.Parse(Console.ReadLine());
Console.Write("introduce lado 3:");
l3 = double.Parse(Console.ReadLine());
t1.asignarlado1(l1);
t1.asignarlado2(l2);
t1.asignarlado3(l3);
Console.WriteLine("area= {0}", t1.area());
Console.WriteLine("perimetro= {0}", t1.perimetro());
Console.ReadKey();
}
}
}

Manipulacion de clases (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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int s;
s = int.Parse(comboBox1.Text);
switch (s)
{
case 1 :
{
Form2 rect = new Form2();
rect.Show();
break;
}
case 2:
{
Form3 cird = new Form3();
cird.Show();
break;
}
case 3:
{
Form4 cir10 = new Form4();
cir10.Show();
break;
}
case 4:
{
Form5 tri = new Form5();
tri.Show();
break;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class Class_rectangulo
{
double ancho;
double largo;
public Class_rectangulo()
{
ancho = 0;
largo = 0;
}
public Class_rectangulo(double w, double h)
{
ancho = w;
largo = h;
}
public double area()
{
return ancho * largo;
}
public double perimetro()
{
return 2 * (largo + ancho);
}
public void asignarlargo(double h)
{
largo = h;
}
public void asignarancho(double w)
{
ancho = w;
}
public double obtenerlargo()
{
return largo;
}
public double obtenerancho()
{
return ancho;
}
}
}

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 WindowsFormsApplication1
{
public partial class Form2 : Form
{
Class_rectangulo r1 = new Class_rectangulo();

public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double l, a;
l = double.Parse(textBox1.Text);
a = double.Parse(textBox2.Text);
r1.asignarlargo(l);
r1.asignarancho(a);
textBox3.Text = r1.area().ToString();
textBox4.Text = r1.perimetro().ToString();
}
}
}
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 WindowsFormsApplication1
{
public partial class Form3 : Form
{
Circulo cir = new Circulo(10);
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Text = cir.area().ToString();
textBox4.Text = cir.perimetro().ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class Circulo
{
double radio;
public Circulo()
{
radio = 0;
}
public Circulo(double r)
{
radio = r;
}
public double area()
{
return Math.PI * Math.Pow(radio, 2);
}
public double perimetro()
{
return 2 * Math.PI + radio;
}
public void asignarradio(double r)
{
radio = r;
}
public double obtenerradio()
{
return radio;
}
}
}

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 WindowsFormsApplication1
{
public partial class Form4 : Form
{
Circulo circ = new Circulo();
public Form4()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double r;
r = int.Parse(textBox2.Text);
circ.asignarradio(r);
textBox3.Text = circ.area().ToString();
textBox4.Text = circ.perimetro().ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class Triangulo
{
double lado1, lado2, lado3;
public Triangulo()
{
lado1 = 0; lado2 = 0; lado3 = 0;
}
public Triangulo(double l1, double l2, double l3)
{
lado1 = l1; lado2 = l2; lado3 = l3;
}
public double area()
{
return Math.Sqrt(((lado1 + lado2 + lado3) / 2) * (((lado1 + lado2 + lado3) / 2) - lado1) * (((lado1 + lado2 + lado3) / 2) - lado2) * (((lado1 + lado2 + lado3) / 2) - lado3));
}
public double perimetro()
{
return lado1 + lado2 + lado3;
}
public void asignarlado1(double l1)
{
lado1 = l1;
}
public void asignarlado2(double l2)
{
lado2 = l2;
}
public void asignarlado3(double l3)
{
lado3 = l3;
}
public double obtenerlado1()
{
return lado1;
}
public double asignarlado2()
{
return lado2;
}
public double asignarlado3()
{
return lado3;
}
}
}

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 WindowsFormsApplication1
{
public partial class Form5 : Form
{
Triangulo tria = new Triangulo();
public Form5()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double l1, l2, l3;
l1 = double.Parse(textBox1.Text);
l2 = double.Parse(textBox2.Text);
l3 = double.Parse(textBox3.Text);
tria.asignarlado1(l1);
tria.asignarlado2(l2);
tria.asignarlado3(l3);
textBox4.Text = tria.area().ToString();
textBox5.Text = tria.perimetro().ToString();
}
}
}

martes, 10 de marzo de 2009

Practica 2 Hoja 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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
double dt = 0, di = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double t;
for (t=0; t <= 10; t++)
{
listBox1.Items.Add(t);
di = (1.0/2.0) * (32 * Math.Pow(t, 2));
listBox2.Items.Add(di);
dt = dt + di;
listBox3.Items.Add(di);
}
}
}
}

Practica 1 Hoja 4 (consola)



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double a, r, n,v,termino,sumatoria=0;
Console.Write("introduce la cantidad de terminos:");
n = double.Parse(Console.ReadLine());
Console.Write("introduce el primer termino:");
a = double.Parse(Console.ReadLine());
Console.Write("introduce la proporcion en comun:");
r = double.Parse(Console.ReadLine());
Console.WriteLine("\t\tsumatoria:");
for (v = 0; v <= n - 1; v++)
{
termino = a * Math.Pow(r, v);
Console.Write(termino);
sumatoria = sumatoria + termino;
if (v == n - 1)
{
Console.Write("=");
}
else
{
Console.Write("+");
}
}
Console.Write(sumatoria);
Console.ReadKey();

}
}
}

lunes, 9 de marzo de 2009

Registrador de pesos de pescados (en 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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
double peso,total=0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Enabled = true;
textBox2.Focus();
}
private void button2_Click(object sender, EventArgs e)
{
double limite,excedida;
textBox2.Focus();
limite = double.Parse(textBox1.Text);
peso = double.Parse(textBox2.Text);
textBox2.Clear();
total = total + peso;
textBox3.Text = total.ToString();
if (total > limite)
{
excedida = total - limite;
label5.Visible = true;
label4.Visible = true;
label6.Visible = true;
textBox4.Visible = true;
textBox4.Text = excedida.ToString();
}
if (peso == 0)
{
label7.Visible = true;
textBox2.Enabled = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
total = 0;
peso = 0;
label5.Visible = false;
label6.Visible = false;
textBox4.Visible = false;
label7.Visible = false;
textBox2.Enabled = true;
textBox1.Clear();
textBox3.Clear();
textBox2.Enabled = false;
textBox1.Focus();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

Registrador de pesos de pescados (en consola)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double limite=0,peso=0,total=0,excedida=0;
Console.Write("introduce el limite de pesca en kg:");
Console.WriteLine("");
limite = double.Parse(Console.ReadLine());
do
{
Console.Write("introduce el peso en kg:");
Console.WriteLine("");
peso = double.Parse(Console.ReadLine());
total = total + peso;
if (total > limitepeso>limite)
{
Console.Write("excedio el limite");
Console.WriteLine("");
Console.Write("total= {0}kg", total);
Console.WriteLine("");
excedida = total - limite;
Console.Write("se excedio con: {0}kg", excedida);
}
else if (total == limite peso== limite)
{
Console.Write("termino");
Console.WriteLine("");
Console.Write("total: {0}kg", total);
}

else if (peso == 0)
{
Console.WriteLine("se termino");
Console.WriteLine("total= {0}kg", total);
}
}
while (total < limite&&total!=0); Console.ReadKey();
}
}
}

domingo, 8 de marzo de 2009

Conceptos básicos (Unidad I)

Lenguaje de alto nivel: es aquel con el que la programación se realiza de una forma más cercana al lenguaje humano.

Lenguaje de bajo nivel: es aquel con el que la programación se realiza de una forma mas cercana al lenguaje maquina (lenguaje binario).

Lenguaje ensamblador: es el lenguaje que se utiliza con términos que son más fáciles de manipular por los humanos, pero equivalen al lenguaje maquina.

Traductor: son programas que toman como entrada un texto escrito en un lenguaje el cual es llamado fuente y entrega como salida otro texto en un lenguaje, denominado objeto.
Compilador: es un tipo de traductor este programa traduce código fuente escrito en un lenguaje de alto nivel en código máquina.

Sistemas numéricos: son un conjunto de símbolos y reglas que se utilizan para representar datos numéricos o cantidades. Cuentan con una base que indica los distintos símbolos que utiliza y con un coeficiente que determina el valor de cada símbolo dependiendo de la posición que ocupe. Ejemplos:
Sistema decimal
Sistema binario
Sistema octal
Sistema hexadecimal

Arquitectura de computadoras: la arquitectura de computadoras se refiere al diseño, estructura y el funcionamiento de estas.
Sistema operativo: es el programa o también se puede ver como un conjunto de programas el cual tiene la tarea de facilitar el uso de una computadora.

Tipos de programación:
Programación estructurada (PE):
La programación estructurada esta compuesta por un conjunto de técnicas que han ido evolucionando aumentando considerablemente la productividad del programa reduciendo el tiempo de depuración y mantenimiento del mismo. Esta programación estructurada utiliza un número limitado de estructuras de control, reduciendo así considerablemente los errores.

Programación orientada a objetos (POO): Se trata de una técnica que aumenta considerablemente la velocidad de desarrollo de los programas gracias a la reutilización de los objetos. El elemento principal de la programación orientada a objetos es el objeto. El objeto es un conjunto complejo de datos y programas que poseen estructura y forman parte de una organización. Un objeto contiene varios datos bien estructurados y pueden ser visibles o no dependiendo del programador y las acciones del programa en ese momento.
Fuente: DesarrolloWeb.com

Lenguajes de programación: son lenguajes artificiales que pueden ser usados para controlar dispositivos, se componen por reglas de escritura y cada dispositivo responderá de acuerdo a estas reglas.

lunes, 2 de marzo de 2009

Hoja 3 Problema2 (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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int opcion;
opcion=int.Parse(comboBox1.Text);
switch (opcion)
{
case 1:
textBox1.Visible = true;
textBox1.Focus();
break;
case 2:
textBox2.Visible = true;
textBox2.Focus();
break;
case 3:
textBox3.Visible = true;
textBox3.Focus();
break;
case 4:
textBox4.Visible = true;
textBox4.Focus();
break;
case 5:
textBox5.Visible = true;
textBox5.Focus();
break;
}

}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = "0";
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "0";
textBox5.Text = "0";
}
private void button2_Click(object sender, EventArgs e)
{
int P1, P2, P3, P4, P5;
double total;
P1 = int.Parse(textBox1.Text);
P2 = int.Parse(textBox2.Text);
P3 = int.Parse(textBox3.Text);
P4 = int.Parse(textBox4.Text);
P5 = int.Parse(textBox5.Text);
total = (P1 * 29.80) + (P2 * 45.00) + (P3 * 99.80) + (P4 * 44.90) + (P5 * 68.75);
textBox6.Visible = true;
textBox6.Text = "$"+total.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
comboBox1.Focus();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

Hoja 3 Problema1 (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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int opcion;
opcion = int.Parse(comboBox1.Text);
switch (opcion)
{
case 1: Form2 f2= new Form2();
f2.Show();
break;
case 2: Form3 f3= new Form3();
f3.Show();
break;
case 3: Form4 f4= new Form4();
f4.Show();
break;
case 4: Form5 f5 = new Form5();
f5.Show();
break;
}
}
}
}


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 WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int lado, area, perimetro;
lado=int.Parse(textBox1.Text);
area = lado * lado;
perimetro = lado * 4;
textBox2.Visible = true;
textBox2.Text= ( area.ToString());
textBox3.Visible = true;
textBox3.Text=(perimetro.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
} 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 WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int largo,ancho, area, perimetro;
largo = int.Parse(textBox1.Text);
ancho = int.Parse(textBox2.Text);
area = largo * ancho;
perimetro = (largo * 2)+(ancho*2);
textBox3.Visible = true;
textBox3.Text = (area.ToString());
textBox4.Visible = true;
textBox4.Text = (perimetro.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

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 WindowsFormsApplication1
{
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double lado1, lado2, lado3,area, perimetro, semiperimetro;
lado1 = double.Parse(textBox1.Text);
lado2 = double.Parse(textBox2.Text);
lado3 = double.Parse(textBox3.Text);
perimetro = (lado1 + lado2 + lado3);
semiperimetro = (perimetro / 2);
area = (Math.Sqrt((semiperimetro) * (semiperimetro - lado1) * (semiperimetro - lado2) * (semiperimetro - lado3)));
textBox4.Visible = true;
textBox4.Text = (area.ToString());
textBox5.Visible = true;
textBox5.Text = (perimetro.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}



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 WindowsFormsApplication1
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double radio, area, perimetro;
radio = int.Parse(textBox1.Text);
area = ((Math.PI)*(Math.Pow(radio,2)));
perimetro = (2*Math.PI*radio);
textBox2.Visible = true;
textBox2.Text = (area.ToString());
textBox3.Visible = true;
textBox3.Text = (perimetro.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox1.Focus();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}