viernes, 2 de octubre de 2009

PRACTICA 4


PRACTICA 4 CUADRANTE (A. consola)


Pseudocodigo
INICIO

double opcion, x, y, o;
double ("Seleccione una operacion a realizar de la siguiente");
double ("1.-Sumar");
double ("2.-Resta");
double ("3.-Multiplicacion");
double ("4.-Division");
Read opcion
double ("Introdusca dato 1");
Read x
double ("Introdusca dato 2");
Read y
if (opcion == 1)
{
o = x + y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 2)
{
o = x - y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 3)
{
o = x * y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 4)
{
if (y == 0)
{
double ("error introduce un numero mayor a 0");
}
else if (y > 0)
{
o = x / y;
double(" EL resultado en suma es :{0}", o);
FIN





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

namespace ConsoleApplication1
{
class Program
{
double opcion, x, y, o;
static void Main(string[] args)
{
double opcion, x, y, o;
Console.WriteLine("Seleccione una operacion a realizar de la siguiente");
Console.WriteLine("1.-Sumar");
Console.WriteLine("2.-Resta");
Console.WriteLine("3.-Multiplicacion");
Console.WriteLine("4.-Division");
opcion = double.Parse(Console.ReadLine());
Console.WriteLine("Introdusca dato 1");
x = double.Parse(Console.ReadLine());
Console.WriteLine("Introdusca dato 2");
y = double.Parse(Console.ReadLine());


if (opcion == 1)
{
o = x + y;
Console.WriteLine(" EL resultado en suma es :{0}", o);
Console.ReadLine();

}

else if (opcion == 2)
{
o = x - y;
Console.WriteLine(" EL resultado en suma es :{0}", o);
Console.ReadLine();

}
else if (opcion == 3)
{
o = x * y;
Console.WriteLine(" EL resultado en suma es :{0}", o);
Console.ReadLine();

}
else if (opcion == 4)
{
if (y == 0)
{
Console.WriteLine("error introduce un numero mayor a 0");
Console.ReadLine();
}
else if (y > 0)
{
o = x / y;
Console.WriteLine(" EL resultado en suma es :{0}", o);
Console.ReadLine();
}

}
}
}
}

PRACTICA 4 (B. visual)

amespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

int angulo ;
angulo = int.Parse(textBox1.Text);
switch (angulo)
{
case 0: ;
break;
case 90: textBox2.Text = ("cuadrante 1");
break;
case 180: textBox2.Text = ("cuadrante 2");
break;
case 270: textBox2.Text = ("cuadrante 3");
break;
case 360: textBox2.Text = ("cuadrante 4");
break;

}

}

private void label2_Click(object sender, EventArgs e)
{

}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

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

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{

textBox1.Clear();

textBox2.Clear();
}
}
}

PRACTICA 4 PIES A METRO (C. consola)

Pseudocodigo
INICIO

double celcius, f;
celcius = -10;
Print (" Celcius Fahrenheit ");
while (celcius <= 60.0) { f = (9.0 / 5.0) * celcius + 32; Print ("celcius " + celcius.ToString() + " = " + f.ToString() + " grados fahrenheit "); celcius = celcius + 10.0;

FIN


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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double celcius, f;
celcius = -10;
Console.WriteLine(" Celcius Fahrenheit ");

Console.ReadLine();

while (celcius <= 60.0) { f = (9.0 / 5.0) * celcius + 32;
Console.WriteLine("celcius " + celcius.ToString() + " = " + f.ToString() + " grados fahrenheit ");
celcius = celcius + 10.0;

} Console.ReadLine(); } } }

PRACTICA 4 (D. visual)


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

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

double pies, m;
pies = 2.0;
listBox1.Items.Add(" Pies a metros ");

while (pies <= 20.0) { m = pies / 3.28; listBox1.Items.Add("Pies " + pies.ToString() + " = " + m.ToString() + " metros "); pies = pies + 2; } } } }


jueves, 24 de septiembre de 2009

PRACTICA 3

PRACTICA 3 AREA DE UN TRIANGULO(A. CONSOLA)

PSEUDOCODIGO
1. INICIO
double radio, altura, volumen, area;
radio = altura = volumen = area = 0;
PRINT("Introduce el valor del radio: ");
READ radio
PRINT("Introduce el valor del altura: ");
READ altura
volumen = (3.14 * radio * radio * altura);
area = (2*3.14*radio*(altura+radio));
PRINT("El volumen es igual a: {0}" , volumen);
PRINT("El area es igual a: {0}", area);
FINAL




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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double radio, altura, volumen, area;
radio = altura = volumen = area = 0;
Console.WriteLine("Introduce el valor del radio: ");
radio = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce el valor del altura: ");
altura = double.Parse(Console.ReadLine());
volumen = (3.14 * radio * radio * altura);
area = (2*3.14*radio*(altura+radio));
Console.WriteLine("El volumen es igual a: {0}" , volumen);
Console.WriteLine("El area es igual a: {0}", area);
Console.ReadKey();
}
}
}

PRACTICA 3 AREA DE UN TRIANGULO (A. 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 radio, altura, volumen, area;
public Form1()
{

InitializeComponent();
radio = altura = volumen = area = 0;

}

private void label2_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

radio = double.Parse(textBox1.Text);

altura = double.Parse(textBox2.Text);
volumen = (3.14 * radio * radio * altura);
area = (2 * 3.14 * radio * (altura + radio));
textBox3.Text=("")+volumen.ToString();
textBox4.Text=("")+area.ToString();

}

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

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}
}
}

PRACTICA 3 Area de un triangulo (B. CONSOLA)

PSEUDOCODIGO
1. INICIO

double P, Area, A, B, C;
PRINT("Introduce las tres longitudes de un triangulo");
READ A
READ B
READ C
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
PRINT("El area del triangulo es: {0}", Area);
FIN

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double P, Area, A, B, C;

Console.WriteLine("Introduce las tres longitudes de un triangulo");
A = double.Parse(Console.ReadLine());
B = double.Parse(Console.ReadLine());
C = double.Parse(Console.ReadLine());
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
Console.WriteLine("El area del triangulo es: {0}", Area);
Console.ReadKey();

}
}
}

PRACTICA 3 Area de un triangulo (B. 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 P, Area, A, B, C;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
A = double.Parse(textBox1.Text);
B = double.Parse(textBox2.Text);
C = double.Parse(textBox3.Text);
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
textBox4.Text = (" ") + Area.ToString();
}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}

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

PRACTICA 3 ALMACEN (C. CONSOLA)

PSEUDOCODIGO
1. INICIO

int codigo,cant, precio, total, descuento, pago;
PRINT("introduce codigo");
READ codigo
PRINT("introduce la cantidad");
READ cant
PRINT("introduce el precio");
READ precio
if (cant > 100)
{
PRINT("descuento 40%");
total = cant * precio;
descuento = (total * 40) / 100;
pago = total - descuento;
}

else
{
if (cant > 24)
{
PRINT("descuento 20%");
total = cant * precio;
descuento = (total * 20) / 100;
pago = total - descuento;
}
else
{
if (cant > 9)
{
PRINT("descuento 10%");
total = cant * precio;
descuento = (total * 10) / 100;
pago = total - descuento;
}
else
{
PRINT("no hay descuento");
total = cant * precio;
descuento = 0;
pago = total - descuento;
}
}
}
PRINT("el total es:{0}", total);
PRINT("el precio final es{0}",pago);

FIN

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int codigo,cant, precio, total, descuento, pago;
Console.WriteLine("introduce codigo");
codigo = int.Parse(Console.ReadLine());
Console.WriteLine("introduce la cantidad");
cant = int.Parse(Console.ReadLine());
Console.WriteLine("introduce el precio");
precio = int.Parse(Console.ReadLine());
if (cant > 100)
{
Console.WriteLine("descuento 40%");
total = cant * precio;
descuento = (total * 40) / 100;
pago = total - descuento;
}

else
{
if (cant > 24)
{
Console.WriteLine("descuento 20%");
total = cant * precio;
descuento = (total * 20) / 100;
pago = total - descuento;
}
else
{
if (cant > 9)
{
Console.WriteLine("descuento 10%");
total = cant * precio;
descuento = (total * 10) / 100;
pago = total - descuento;
}
else
{
Console.WriteLine("no hay descuento");
total = cant * precio;
descuento = 0;
pago = total - descuento;
}
}
}

Console.WriteLine("el total es:{0}", total);
Console.WriteLine("el precio final es{0}",pago);
Console.ReadKey();
}
}
}


PRACTICA 3 (C. 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
{
int cant,precio,total,descuento,pago;
public Form1()
{
cant = precio = total = descuento = pago = 0;
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

private void bxTotal_TextChanged(object sender, EventArgs e)
{

}

private void Calcular_Click(object sender, EventArgs e)
{
cant = int.Parse(bxcant.Text);
precio = int.Parse(bx.Text);
total = cant * precio;
bxTotal.Text = total.ToString();
if (cant > 100)
{
descuento = (total * 40) / 100;
bxDescuento.Text =descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();

}
else
if (cant > 24)
{
descuento = (total * 20) / 100;
bxDescuento.Text =descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
else
if (cant > 9)
{
descuento = (total * 10) / 100;
bxDescuento.Text = descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
else
descuento = 0;
bxDescuento.Text = descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}

private void Limpiar_Click(object sender, EventArgs e)
{
bx.Clear();
bxcant.Clear();
bxDescuento.Clear();
bxPago.Clear();
bxTotal.Clear();
}

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


}

}

PRACTICA 3 CELCIUS Y FAHRENHEIT (D. CONSOLA)

PSEUDOCODIGO
1. INICIO

double t, f, c;
string g;
PRINT ("Introduce el valor de la temperatura:");
READ t
PRINT ("Introduce grados fahrenheit (f°) o grados celcius (c°):");
READ g
if (g=="f" || g=="F")
{
c = (5.0 / 9.0) * (t - 32.0);
PRINT ("La temperatura de " + t + " f° es igual a " + c + " c° ", t, c);
}
if (g=="c" || g=="C")
{
f = (9.0/5.0)*t + 32.0;
PRINT ("La temperatura de " + t + " c° es igual a " + f + " f° ", t, f);
}
if (g != "c" || g != "f" && g != "C" || g != "F")
{
PRINT ("El factor de conversion no es correcto");
FIN

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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double t, f, c;
string g;

Console.Write("Introduce el valor de la temperatura:");
t = double.Parse(Console.ReadLine());

Console.Write("Introduce grados fahrenheit (f°) o grados celcius (c°):");
g = Console.ReadLine();

if (g=="f" || g=="F")
{
c = (5.0 / 9.0) * (t - 32.0);
Console.WriteLine("La temperatura de " + t + " f° es igual a " + c + " c° ", t, c);
Console.ReadLine();
}

if (g=="c" || g=="C")
{
f = (9.0/5.0)*t + 32.0;
Console.WriteLine("La temperatura de " + t + " c° es igual a " + f + " f° ", t, f);
Console.ReadLine();
}

if (g != "c" || g != "f" && g != "C" || g != "F")
{
Console.Write("El factor de conversion no es correcto");
Console.ReadKey();
}
}
}

}


PRACTICA 3CELCIUS Y FAHRENHEIT (D. VISUAL)

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 t, f, c;
string g;
public Form1()
{
InitializeComponent();
t = f = c = 0;
g = " ";
}

private void button1_Click(object sender, EventArgs e)
{
t = double.Parse(textBox1.Text);
g = textBox2.Text;

if (g == "f" || g == "F")
{
c = (5.0 / 9.0) * (t - 32.0);
textBox3.Text = c.ToString();
}
else
{
if (g == "c" || g == "C")
{
f = (9.0 / 5.0) * t + 32.0;
textBox3.Text = f.ToString();
}
else
{
if (g != "c" || g != "f" || g != "C" || g != "F")
{

textBox3.Text = "Presiono opcion equivocada";
}
}
}
}



private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
}
}