20090930

PRACTICA 4.1 SELECCION DE OPERACIONES (visual)



MODO VISUAL ,. PARA EL CALCULO DE OPERACIONES ACONTINUACION EL PROGRMA EJECUTABLE.


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)
{
double primero, segundo, codigo, resultado;
primero = double.Parse(textBox1.Text);
segundo = double.Parse(textBox2.Text);
codigo = double.Parse(textBox3.Text);
if (codigo == 1)
{
resultado = primero + segundo;
textBox4.Text = resultado.ToString();
}
else if (codigo == 2)
{
resultado = primero - segundo;
textBox4.Text = resultado.ToString();
}
else if (codigo == 3)
{
resultado = primero * segundo;
textBox4.Text = resultado.ToString();
}
else if (codigo == 4)
{
if (segundo == 0)
{
MessageBox.Show("Error introduce el en el segundo numero un valor mayor a cero");
textBox2.Clear();
}
else if (segundo > 0)
{
resultado = primero / segundo;
textBox4.Text = resultado.ToString();
}
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();

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

PRACTICA 4.1 SELECCION DE OPERACIONES(consola)

pseudocodigo.
inicio
double opcion, x, y, o;
static void Main()
{
double opcion, x, y, o;
print("SELECCIONE UNA OPERACION PARA SU REALIZACION");
print("1.-SUMAR");
print("2.-RESTAR");
print("3.-MULTIPLICAR");
print("4.-DIVIDIR");
Read opcion
print("INTRODUCE EL PRIMER DATO 1");
Read x
print("ITRODUCE EL SEGUNDO DATO 2");
Read y
if (opcion == 1) { o = x + y;
print(" EL RESULTADO ES:{0}", o);
Console.ReadLine();
}
else if (opcion == 2) { o = x - y;
print("EL RESULTADO ES :{0}", o);
Console.ReadLine();
} else if (opcion == 3)
{ o = x * y;
print(" EL RESULTADO ES :{0}", o);
Console.ReadLine();
} else if (opcion == 4)
{ if (y == 0)
{
print("ERROR INTRODUCE UN NUMERO MAYOR A CERO 0");
Console.ReadLine();
}
else
if (y > 0) { o = x / y;
print(" EL RESULTADO ES :{0}", o);
}fin.







ESCRIBA UN PROGRAMA QUE ACEPTE DOS NUMEROS REALES DE USUARIO Y UN CODIGO DE SELECCION. SI EL CODIGO DE INTRODUCCION ES 1, HAGA QUE EL PROGRAMA SUME 2 NUMEROS Y DESPLIEGUE RESULTADO; SI EL CODIGO DE SELECIION ES 2 , LOS NUMEROS DEBERAN SER RESTADOS, SI EL CODIGO DE ESELECCION ES 3, LOS NUMEROS DEBERAN SER MULTIPLICADOS, SI EL CODIGO DE SELECCION ES 4 , DEVERA DIVIDIR EL PRIMER NUMERO SOBRE EL SEGUNDO, NO PERMITA LA DIVISION ENTRE CERO, Y DESPLIEGUE UN MESAJE APROPIADO CUANDO SE INTENTE ESTA DIVISION.







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 PARA SU REALIZACION");
Console.WriteLine("1.-SUMAR");
Console.WriteLine("2.-RESTAR");
Console.WriteLine("3.-MULTIPLICAR");
Console.WriteLine("4.-DIVIDIR");
opcion = double.Parse(Console.ReadLine());
Console.WriteLine("INTRODUCE EL PRIMER DATO 1");
x = double.Parse(Console.ReadLine());
Console.WriteLine("ITRODUCE EL SEGUNDO DATO 2");
y = double.Parse(Console.ReadLine());

if (opcion == 1)
{
o = x + y;
Console.WriteLine(" EL RESULTADO ES:{0}", o);
Console.ReadLine();
}
else if (opcion == 2)
{
o = x - y;
Console.WriteLine("EL RESULTADO ES :{0}", o);
Console.ReadLine();
}
else if (opcion == 3)
{
o = x * y;
Console.WriteLine(" EL RESULTADO ES :{0}", o);
Console.ReadLine();
}
else if (opcion == 4)
{
if (y == 0)
{
Console.WriteLine("ERROR INTRODUCE UN NUMERO MAYOR A CERO 0");
Console.ReadLine();
}
else if (y > 0)
{
o = x / y;
Console.WriteLine(" EL RESULTADO ES :{0}", o);
Console.ReadLine();
}
}
}
}
}










PRACTICA 4.2 DESPLIEGUE DE CUADRANTE (visual)



PROGRAMA EN EJECUTABLE PARA DESPELGAR UBICACION DE CUADRANTE DEPENDIENDO EL ANGULO.



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 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 button2_Click_1(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}

PRACTICA 4.2 DESPLIEGUE DE CUADRANTE(consola)

Pseudocodigo.
inicio
int angulo;
print " INTRODUCE ANGULO"
Read angulo
if (angulo>0&&angulo<90)
print "cuadrante 1"
else
{
if (angulo > 90 && angulo < 180)
print("cuadrante 2");
else {
if (angulo > 180 to angulo < 270)
print("cuadrante 3");
else
{
if (angulo > 270 to angulo < 370)
print ("cuadrante 4");
switch (angulo)
{
case 0: case 360: print ("eje positivo")
break;
case 90: print ("eje positivo")
break;
case 180: print("eje negativo")
break;
case 270: print("eje negativo")
break;
fin.



EL CUADRANTE EN EL CAUL SE UBICA LA LINEA DIBUJADA DESDE EL ORIGEN ESTA DETERMINADO POR EL ANGULO QUE LA LINEA FORMA CON EL EJE POSITIVO DE X EN LA SIGUINETE FEROMA.


ENTRE 0 Y 90 GRADOS 1

ENTRE 90 Y 180 GRADOS 2

ENTRE 180Y 270 GRADOS 3

ENTRE 270 Y 360 GRADOS 4


UTILIZANDO ESTA INFORMACION, ESCRIBA UN PROGRAMA QUE ACEPTE EL ANGULO DE LA LINEA COMO DATO DE ENTRADA POR EL USUARIO Y QUE DESPLIEGUE EL CAUDRANTE APROPIADO ACONFORME A LOS DATOS.





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int angulo;
Console.WriteLine("\t\t INTRODUCE ANGULO");
angulo=int.Parse(Console.ReadLine());
if (angulo>0&&angulo<90)
Console.WriteLine("cuadrante 1");
else
{
if
(angulo > 90 && angulo < 180)
Console.WriteLine("cuadrante 2");
else { if (angulo > 180 && angulo < 270)
Console.WriteLine("cuadrante 3");
else
{
if (angulo > 270 && angulo < 370)
Console.WriteLine("cuadrante 4");
switch (angulo)
{
case 0: case 360: Console.WriteLine("eje positivo"); break;
case 90: Console.WriteLine("eje positivo"); break;
case 180: Console.WriteLine("eje negativo"); break;
case 270: Console.WriteLine("eje negativo"); break;
Console.ReadKey(); } } } } } } }

PRACTICA 4.3 TABLA DE GRADOS A FAHREHEIT (visual)





EJECUTABLE DE FORMA VISUAL PARA LA TALA DE CONVERSIONDE GRADOS.

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)
{
double celcius, f;
celcius = -10;
listBox1.Items.Add(" Celcius Fahrenheit ");
while (celcius <= 60.0) { f = (9.0 / 5.0) * celcius + 32; listBox1.Items.Add("celcius " + celcius.ToString() + " = " + f.ToString() + " grados fahrenheit "); celcius = celcius + 10.0; }
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}

PRACTICA 4.3 TABLA DE GRADOS A FAHRENHEIT

pseurdocodigo.
inicio
double celcius, f celcius = -10
print" Celcius Fahrenheit "
while celcius <= 60.0)
{
f = (9.0 / 5.0) * celcius + 32;
print "celcius " + celcius. " grados fahrenheit "
celcius = celcius + 10.0;
}
fin.





HAGA UN PROGRAMA PARA PRODUCIR UN ATABLA QUE EMPIECE CON UN VALOR DE CELCIUS -10 Y TERMINE CON UN VALOR DE CELSIUS DE 60, EN INCREMENTOS DE 10 GRADOS PARA CONVERTIRLA EN GRADOS FAHRENHEIT. FAHREN=(9.0/5.0)*CELSIUS+32.0


PROGRAMA ESCRITO PARA LA TABLA DE CONVERSION ,. (ejecutable)


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.4 CONVERSION PIES A METROS (visual)


PROGRAMA ESCRITO,. PARA EL CALCULO DE PIES A METROS DE LA FORMA VISUAL,. SIN PEDIR DATO ALGUNO,.SOLO DESPLIEGA LOS INCEREMENTOS DE PIES ,. Y EL RESULATADO EN METROS.


A CONTINAUCION EL PROGRAMA 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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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;
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}