
CODIGO EN CONSOLA
static void Main(string[] args)
{
double temp,f,c;
char tipo;
Console.WriteLine("Introduce el valor de la Temperatura");
temp = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce letra [ F ] para fahrenheit o [ C] para Celcuis");
tipo=char.Parse(Console.ReadLine());
if (tipo == 'f' || tipo == 'F')
{
c = (5.0 / 9.0) * (temp - 32.0);
Console.WriteLine(" La temperatura " + temp + " Fahrenheit es igual a \n" + c + " grados celcuis ", temp, c);
Console.ReadLine();
}
else
{
if (tipo == 'c' || tipo == 'C')
{
f = (9.0 / 5.0) * temp + 32.0;
Console.WriteLine(" La temperatura " + temp + " Celcuis es igual a \n " + f + " grados Fahrenheit ", temp, f);
Console.ReadLine();
}
else
{
Console.WriteLine("Datos incorectos");
}
}

CODIGO EN WINDOWS
private void button1_Click(object sender, EventArgs e)
{
double temp, f, c;
char tipo;
temp = double.Parse(textBox1.Text);
tipo = char.Parse(textBox2.Text);
if (tipo == 'f' || tipo == 'F')
{
c = (5.0 / 9.0) * (temp - 32.0);
label3.Text=(" La temperatura " + temp + " Fahrenheit es igual a \n" + c + " grados celcuis ");
}
else
{
if (tipo == 'c' || tipo == 'C')
{
f = (9.0 / 5.0) * temp + 32.0;
label3.Text=(" La temperatura " + temp + " Celcuis es igual a \n " + f + " grados Fahrenheit ");
}
else
{
Console.WriteLine("Datos incorectos");
label3.Text="";
}
}

No hay comentarios:
Publicar un comentario