
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace lab01
{
  public partial class Form1 : Form
  {
      static int tempFahr;
      static int tempCelsius;
      public Form1()
      {
          InitializeComponent();
      }
      private void button1_Click(object sender, EventArgs e)
      {
          try
          {
              if (radioButton1.Checked == true)
              {
                  tempFahr = Convert.ToInt32(maskedTextBox1.Text);
                  textBox1.Text = Convert.ToString((tempFahr - 32) * 5 / 9);
              }
              else
              {
                  if (radioButton2.Checked == true)
                  {
                      tempCelsius = Convert.ToInt32(maskedTextBox1.Text);
                      textBox1.Text = Convert.ToString((tempCelsius + 32) * 9 / 5);
                  }
                  else
                  {
                      MessageBox.Show("Yunaas Yu ruu xorvuulex geed bgan be");
                  }
              }
          }
          catch (FormatException) { MessageBox.Show("Too bich"); }
      }
  
  }
}
 
No comments:
Post a Comment