Quantcast
Viewing all articles
Browse latest Browse all 12583

Novice programmer trying to complete a Temp Converter Program.

Hi, I need help finishing this temp converter, I need to enter the temperature i wish to convert to either Celsius or Fahrenheit to text box and choose from to radio buttons to either convert it to Fahrenheit or Celsius and then display the answer in a label. The code that i made does compile, but it gives me an error each time I press the convert button this is what i got so far:

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

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void rbF2C_CheckedChanged(object sender, EventArgs e)
        {
            double celsius = System.Double.Parse(txtCelcius);
            double fahrenheit = (celsius * 9 / 5) + 32;
        }


        private void rbC2F_CheckedChanged(object sender, EventArgs e)
        {
            double fahrenheit = System.Double.Parse(txtFahrenheit);
            double celsius = (fahrenheit - 32) * 5 / 9;
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            string value = "";
            bool isChecked = rbF2C.Checked;
            if (isChecked)
                value = rbF2C.Text;
            else
                value = rbC2F.Text;
        }

        public string txtCelcius { get; set; }

        public string txtFahrenheit { get; set; }
    }
}


Viewing all articles
Browse latest Browse all 12583

Trending Articles