lunes, 22 de febrero de 2010

practica 5


Practica 5_1 visual


sing 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 ga;
double mi;
double rendimiento;
public Form1()
{
InitializeComponent();
ga = mi = rendimiento=0;
}

private void button1_Click(object sender, EventArgs e)
{
mi = double.Parse(textBox1.Text);
ga = double.Parse(textBox2.Text);
rendimiento = mi / ga;
label3.Text = "rendimiento millas por galon = " + rendimiento;
}
}
}

Practica 5_1 consola

using System;
using System.Collections.Generic;

using System.Linq;
using System.Text; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("Introduzca las millas recorridas: ");

double millas = Double.Parse(Console.ReadLine());
Console.WriteLine("\nIntroduzca los galones de gasolina consumidos");
double galones = double.Parse(Console.ReadLine());
double rendimiento = millas/galones;
Console.WriteLine ("la cantida consumida millas por galon es = {0:f4}", rendimiento); Console.ReadKey();
}
}
}


Practica 5_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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
double r, a, b, c, x;
public Form1()
{
InitializeComponent();
r = a = b = c = x = 0;
}
private void button1_Click(object sender, EventArgs e)
{
a = double.Parse(textBox1.Text);
b = double.Parse(textBox2.Text);
c = double.Parse(textBox3.Text);
x = double.Parse(textBox4.Text);
r = a * Math.Pow(x, 2) + b * x + c;
label5.Text = "el resultado del polinomio es " + r;
}
private void button2_Click(object sender, EventArgs e)
{

textBox1.Clear();

textBox2.Clear();
textBox3.Clear();

textBox4.Clear();
textBox1.Focus();
}
}

}

Practica 5_2 consola

using System;
using System.Collections.Generic;

using System.Linq; using System.Text;
namespace ConsoleApplication1
{
class Program

{

static void Main(string[] args)
{
Console.WriteLine("Programa que calcula el valor de polinomio de segundo orden");
Console.WriteLine("introduce el valor de A"); double a = double.Parse(Console.ReadLine()); Console.WriteLine("introduce el valor de B"); double b = double.Parse(Console.ReadLine()); Console.WriteLine("introduce el valor de C"); double c = double.Parse(Console.ReadLine()); Console.WriteLine("introduce el valor de X "); double x = double.Parse(Console.ReadLine()); double resultado = a*Math.Pow(x,2) + b*x + c;
Console.WriteLine(" el valor del polinomio es = " + resultado);
Console.ReadKey();

}
}
}


Practica 5_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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
double angulo;
public Form1()
{
InitializeComponent();
angulo = 0;
}

private void button1_Click(object sender, EventArgs e)
{
angulo = double.Parse(textBox1.Text);
if (angulo < text="angulo agudo" angulo ="=" text="angulo recto" text="angulo obtuso " text = " ">

practica 5_3 consola

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Introduce el angulo"); double angulo = double.Parse(Console.ReadLine()); if (angulo <> { Console.WriteLine("angulo agudo"); } else { if (angulo == 90) { Console.WriteLine("angulo recto"); } else { Console.WriteLine("angulo obtuso "); } } Console.ReadKey(); } } }



Practica 5_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 c1,c2,c3,c4,c5, promedio;
string nombre;
public Form1()
{
InitializeComponent();
c1 = c2 = c3 = c4 = c5 = promedio = 0;
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
nombre= textBox1.Text;
c1 = double.Parse(textBox2.Text);
c2 = double.Parse(textBox3.Text);
c3 = double.Parse(textBox4.Text);
c4 = double.Parse(textBox5.Text);
c5 = double.Parse(textBox6.Text);
promedio = (c1 + c2 + c3 + c4 + c5) / 5;
if (promedio >= 70)
{
label7.Text = "alumno aprobado " + nombre + "promedio " + promedio;
}
else
{
label7.Text = "alumno no acreditado " + nombre + " promedio " + promedio;
}


}

private void button2_Click(object sender, EventArgs e)
{

}
}
}


Practica 5_4 consola


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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Introduce nombre del alumno");
string nombre = Console.ReadLine();
Console.WriteLine("Introduce calficacion 1");
double c1 = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce calficacion 2");
double c2 = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce calficacion 3");
double c3 = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce calficacion 4");
double c4 = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce calficacion 5");
double c5 = double.Parse(Console.ReadLine());
double promedio = (c1 + c2 + c3 + c4 + c5) / 5;
if (promedio >= 70)
{
Console.WriteLine("alumno aprobado " + nombre + " Promedio {0:f4} " , promedio);
}
else
{
Console.WriteLine("alumno no acreditado " + nombre + " Promedio {0:f4} " , promedio);
}

Console.ReadKey();

}
}
}

practica 5_5






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

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n1, n2, n3, n4, n5, mayor = 0;
Console.Write("introduce numero 1:");
n1 = int.Parse(Console.ReadLine());
Console.Write("introduce numero 2:");
n2 = int.Parse(Console.ReadLine());
Console.Write("introduce numero 3:");
n3 = int.Parse(Console.ReadLine());
Console.Write("introduce numero 4:");
n4 = int.Parse(Console.ReadLine());
Console.Write("introduce numero 5:");
n5 = int.Parse(Console.ReadLine());
if (n1 >= n2 && n1 >= n3 && n1 >= n4 && n1 >= n5)
{
mayor = n1;
}
else
{
if (n2 >= n1 && n2 >= n3 && n2 >= n4 && n2 >= n5)
{
mayor = n2;
}
else
{
if (n3 >= n1 && n3 >= n2 && n3 >= n4 && n3 >= n5)
{
mayor = n3;
}
else
{
if (n4 >= n1 && n4 >= n2 && n4 >= n3 && n4 >= n5)
{
mayor = n4;
}
else
{
if (n5 >= n1 && n5 >= n2 && n5 >= n3 && n5 >= n4)
{
mayor = n5;
}
}
}
}
}
Console.WriteLine("el dato mayor es {0} ", mayor);
Console.ReadKey();
}
}
}





practica 5_5 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 n1, n2, n3, n4, n5, mayor;
public Form1()
{
InitializeComponent();
n1 = n2 = n3 = n4 = n5 = mayor = 0;
}

private void button1_Click(object sender, EventArgs e)
{
n1 = int.Parse(textBox1.Text);
n2 = int.Parse(textBox2.Text);
n3 = int.Parse(textBox3.Text);
n4 = int.Parse(textBox4.Text);
n5 = int.Parse(textBox5.Text);
if (n1 >= n2 && n1 >= n3 && n1 >= n4 && n1 >= n5)
{
mayor = n1;
}
else
{
if (n2 >= n1 && n2 >= n3 && n2 >= n4 && n2 >= n5)
{
mayor = n2;
}
else
{
if (n3 >= n1 && n3 >= n2 && n3 >= n4 && n3 >= n5)
{
mayor = n3;
}
else
{
if (n4 >= n1 && n4 >= n2 && n4 >= n3 && n4 >= n5)
{
mayor = n4;
}
else
{
if (n5 >= n1 && n5 >= n2 && n5 >= n3 && n5 >= n4)
{
mayor = n5;
}
}
}
}
}
label6.Text = " el dato mayor " + mayor;
}

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

No hay comentarios:

Publicar un comentario