martes, 23 de febrero de 2010

Practica 5 en "Visual".

Practica 5 Problema 1
Codigo:
namespace practica_5_problema_1_visual
{
public partial class Form1 : Form
{
double m, g, r;
public Form1()
{
InitializeComponent();
m = g = r = 0.0;
}

private void button1_Click(object sender, EventArgs e)
{
m = double.Parse(textBox1.Text);
g = double.Parse(textBox2.Text);
r = m / g;
label3.Text = ("El rendimiento en millas por galon=" + r);

}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
label3.Text = " ";
}

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



Practica 5 Problema 2
Codio:
namespace practica_5_problema_2_visual
{
public partial class Form1 : Form
{
double a, b, c, x, poli;
public Form1()
{

InitializeComponent();
a = b = c = poli = 0.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);
poli = (a * Math.Pow(x, 2)) + (b * x) + c;

label5.Text = ("El valor del polinomio es="+poli);


}

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

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



Practica 5 Problema 3
Codigo:
namespace practica_5_problema_3_visual
{
public partial class Form1 : Form
{
double angulo;
public Form1()
{
InitializeComponent();
angulo = 0.0;
}

private void button1_Click(object sender, EventArgs e)
{
angulo = double.Parse(textBox1.Text);
if (angulo < 90)
{
label2.Text = ("El angulo es agudo");
}
else
{
if (angulo == 90)
{
label2.Text=("El angulo es recto");
}
else
{
if (angulo > 90)
{
label2.Text=("El angulo es obtuso");
}
}
}

}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
label2.Text = " ";

}

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



Practica 5 Problema 4
Codigo:
namespace practica_5_problema_4_visual
{
public partial class Form1 : Form
{
double c1, c2, c3, c4, c5, promedio;
string nombre;
public Form1()
{
InitializeComponent();
nombre = " ";
c1 = c2 = c3 = c4 = c5 = 0.0;
}

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;
label15.Text = ("Promedio General="+promedio);
if (promedio < 70)
{
label16.Text = ("La presente boleta certifica que el alumno(a) " + nombre);
label17.Text = (" no acredito el segundo semestre");
}
else
{
if (promedio >= 70)
{
label16.Text = ("La presente boleta certifica que el alumno(a) " + nombre);
label17.Text = (" acredito el segundo semestre");
}
}

}

private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
label15.Text = " ";
label16.Text = " ";
label17.Text = " ";

}

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



Practica 5 Problema 5
Codigo:
namespace practica_5_problema_5_visual
{
public partial class Form1 : Form
{
double n1, n2, n3, n4, n5, mayor;
public Form1()
{
InitializeComponent();
n1 = n2 = n3 = n4 = n5 = 0.0;
}

private void button1_Click(object sender, EventArgs e)
{
n1 = double.Parse(textBox1.Text);
n2 = double.Parse(textBox2.Text);
n3 = double.Parse(textBox3.Text);
n4 = double.Parse(textBox4.Text);
n5 = double.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
{
mayor = n5;
}
}
}
}
label6.Text = ("El numero mayor es ="+mayor);





}

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

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

No hay comentarios:

Publicar un comentario