20090925

PRACTICA 3.4 CONVERSION DE TEMPERATURA (visual)





ESTRUCTURA EN FORMA VISUAL PARA LA CONVERSION DE TEMPERATURA.



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 Prac._3._4_Grados_F__o_C_
{
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();
}

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

No hay comentarios:

Publicar un comentario