2011.10.18 家庭作業:請設計一個可以進行溫度轉換的視窗程式 (攝氏轉華氏, 華氏轉攝氏)。
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
double f = Double.Parse(textBox1.Text);
double c = 0.0;
c = (f - 32) * 5 / 9;
textBox2.Text = c.ToString();
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
double c = Double.Parse(textBox3.Text);
double f = 0.0;
f = c * 9 / 5 + 32 ;
textBox4.Text = f.ToString();
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
private void label4_Click(object sender, EventArgs e)
{
}
}
}





