Temperature Converter

 Design an application which will have 2 radio buttons. One will convert the Celsius to Fahrenheit and another will convert Fahrenheit to Celsius. Show the appropriate output depends on the user’s selection. (Use radio button to take user choice and use textbox to enter value).


Design:- 


Code:- 

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 Temperatureconverter
{
    public partial class frmtemparature : Form
    {
        public frmtemparature()
        {
            InitializeComponent();
        }

        private void lbltemparatureconvertar_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnresult_Click(object sender, EventArgs e)
        {
           
            if (rdctof.Checked == true)
            {
                double c,f;
                c = Convert.ToDouble(txtentertem.Text);
                f = (c * 9/5 + 32);
                txtresult.Text= Convert.ToString(f);
            }
            else if (rdftoc.Checked == true)
            { 
                double c,f;
                f = Convert.ToDouble(txtentertem.Text);
                c = (f - 32) * 5 / 9;
                txtresult.Text = Convert.ToString(c);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnreseat_Click(object sender, EventArgs e)
        {
            txtentertem.Text = " ";
            txtresult.Text = " ";
            rdctof.Checked = false;
            rdftoc.Checked = false;
        }

        private void frmtemparature_Load(object sender, EventArgs e)
        {
        }
    }
}


No comments:

Post a Comment

Aarsh Prajapati

Welcome! Java Programs And Theory  Practical    Theory Java Basic Program Java Simple Program Array, Inheritance and Interface Program Packa...