domingo, 18 de septiembre de 2016

Práctica 7. Conversor de Temperatura


Código:
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 Practica_7
{
    public partial class Form1 : Form
    {
        public Form1()
        {

            InitializeComponent();

        }
        private void btnConvertir_Click(object sender, EventArgs e)
        {
            double grados, convertir1, c;

            if (txtFarenheit.Text == "")
            {
                grados = Convert.ToDouble(txtCentigrados.Text);

                convertir1 = (grados * 9) / 5;

                c = convertir1 + 32;

                txtFarenheit.Text = Convert.ToString(c);
            }
            if (txtCentigrados.Text == "")
            {
                double faren, convertir2, v;

                faren = Convert.ToDouble(txtFarenheit.Text);

                convertir2 = faren - 32;

                v = convertir2 / 1.8;

                txtCentigrados.Text = Convert.ToString(v);
            }
        }
        private void btnLimpiar_Click(object sender, EventArgs e)

        {
            txtCentigrados.Text = "";

            txtFarenheit.Text = "";
        }

        private void btnSalir_Click(object sender, EventArgs e)

        {
            Close();
        }
    }
}

No hay comentarios:

Publicar un comentario