C#计算器实验报告班级:2010134学号:*********姓名:***一实验目的和要求设计一个简单计算器,具有一般计算功能,能进行基本的加减乘除运算,还具有求根号,倒数等功能。
特点是能进行不同进制的运算和不同进制间的转换。
主要的工作主要是操作数与被操作数进行简单的加、减、乘、除运算来完成基本的,而且还可以进行简单的科学运算例如计算一个数的平方、开方、正弦、余弦、log、ln等操作还可以计算面积、周长、体积和表面积等。
通过新的技术和新方法来实现计算功能显示界面为Windows From窗体。
二功能模块设计标准计算器通过Windows Form窗体中的对应按钮接受用户输入数据提交对应的方法中来完成相应的功能计算再将结果显示在显示框内。
显示界面为Windows From窗体。
下面是一个简单的计算器的基本功能:1加法两个数据进行加操作可以为小数。
2减法两个数据进行减操作可以为负数相减。
3乘法两个数相乘4除法两个数相除5 倒数可以求得一个数的倒数6开方开方后的结果可以精确到16位。
科学计算器1平方接收的数相乘结果保留一位小数。
2立方接收的数相乘两次3正弦正弦结果精确度同开方。
4余弦余弦结果精确度同上。
5 LogLog运算精确到16位。
6 Ln以e为底的对数。
7 二进制二进制数的运算8 八进制八进制数的运算9 十进制十进制数的运算11 十六进制十六进制的运算12 倒数可以求得一个数的倒数13 开方开方后的结果可以精确到16位。
14 颜色可以选择输入字体的颜色三设计界面标准型科学型四详细设计过程(一)打开VS2010创建项目(二)界面设计1.进入界面2.菜单设计(1)选择VS201的菜单栏中的“视图|工具箱”单击,调出工具箱(出现在VS用户区左侧。
(2)在工具箱中选择“菜单和工具栏|MenuStrip”,拖到程序界面用户区,并根据自己的喜好在“属性窗口”(可以使用“视图|属性窗口”调出,一般在用户区右下角)设置菜单栏宽度、颜色等。
(3)在菜单栏中“请在此处键入”编辑第一个菜单选项及其下拉子菜单选项“编辑”“复制”“粘贴”。
(4)按上述操作,依次完成第二、三个菜单选项及其下拉子菜单选项。
3.显示条设计(1)在VS用户区左侧工具箱中找到TextBox控件拖到计算器用区合适的位置,按住鼠标左键在相应调整点设置其长度,设置其高度时需要首先在属性窗口把该控件的Mutiline属性设置为True,才可以使用鼠标调整其高度。
(2)在属性窗口设置显示条属性:(Name)属性为txt_Result;Text 属性为0.(即:控件上显示的内容);TextAlign属性为Right;4.其它控件设计向窗体上添加控件,计算器分为3个模块,分别是Textbox:显示区:显示数字和计算结果的功能button:计算区:提供运算符和数字,与用户交互进行运算radioButton:转换区:用于进制之间的转换五详细代码标准型using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication6{public partial class Form1 : Form{public Form1(){InitializeComponent();}public string number;public int x;public double number1;private string a;private string abc;private void button0_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button1_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button2_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button3_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button4_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button9_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button8_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button7_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button6_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text;}private void button5_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text};private void C_Click(object sender, EventArgs e){txt_Result.Text = "";this.btn_Result.Focus();}private void sqrt_Click(object sender, EventArgs e){if (Convert.ToDouble(txt_Result.Text) < 0){this.txt_Result.Text = "error";}else{number1 = Convert.ToDouble(txt_Result.Text);number = "";txt_Result.Text = Convert.ToString(System.Math.Sqrt(number1));} this.btn_Result.Focus();}private void dao_Click(object sender, EventArgs e){if (Convert.ToDouble(txt_Result.Text) == 0){this.txt_Result.Text = "error";}else{number1 = Convert.ToDouble(txt_Result.Text);number = "";txt_Result.Text = Convert.ToString(1 / number1);}this.btn_Result.Focus();}private void dian_Click(object sender, EventArgs e){try{number = Convert.ToString(number + ".");txt_Result.Text = Convert.ToString(number + "");}catch{ }this.btn_Result.Focus();}private void Backspace_Click(object sender, EventArgs e){if (txt_Result.Text == "" || txt_Result.Text == "0"){txt_Result.Text = "";}else{number1 = Convert.ToDouble(txt_Result.Text);number = Convert.ToString((number1 - number1 % 10) / 10);txt_Result.Text = number;}this.btn_Result.Focus();}private void bai_Click(object sender, EventArgs e){number = Convert.ToString(Convert.ToDouble(txt_Result.Text) / 100); txt_Result.Text = number;number = "";this.btn_Result.Focus();}private void zhengfu_Click(object sender, EventArgs e){number1 = Convert.ToDouble(txt_Result.Text);txt_Result.Text = Convert.ToString(0 - number1);this.btn_Result.Focus();}private void X2_Click(object sender, EventArgs e){if (txt_Result.TextLength > 0){number1 = Convert.ToDouble(number);number = Convert.ToString(number1 * number1);txt_Result.Text = number;number = "";}this.btn_Result.Focus();}private void帮助ToolStripMenuItem_Click(object sender, EventArgs e){MessageBox.Show(“这是一个仿照windows的计算器应用程序,功能虽然不齐但基本能运行”);}private void退出ToolStripMenuItem_Click(object sender, EventArgs e){Close();}private void btn_Add_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; }private void btn_Minus_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; }private void btn_Multiply_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; }private void tn_Divide_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; }private void btn_Result_Click(object sender, EventArgs e){d ouble d_result;string s_txt = txt_Result.Text;int space = s_txt.IndexOf(' ');string s1 = s_txt.Substring(0, space);char operation = Convert.ToChar(s_txt.Substring((space + 1), 1));string s2 = s_txt.Substring(space + 3);double arg1 = Convert.ToDouble(s1);double arg2 = Convert.ToDouble(s2);switch (operation){case'+':d_result = arg1 + arg2;break;case'-':d_result = arg1 - arg2;break;case'*':d_result = arg1 * arg2;break;case'/':if (arg2 == 0){throw new ApplicationException();}else{d_result = arg1 / arg2;} break;default:throw new ApplicationException();}txt_Result.Text = d_result.ToString(); }private void标准型TToolStripMenuItem_Click(object sender, EventArgs e) {Form1 frm = new Form1();frm.Show();this.Hide();}private void粘贴ToolStripMenuItem_Click(object sender, EventArgs e){if (a == null){this.txt_Result.Text = this.abc;this.a += this.abc;}else if (a != null && txt_Result.Text != null){this.txt_Result.Text = null;a = null;this.txt_Result.Text = this.abc;this.a += this.abc;}}private void复制CToolStripMenuItem_Click(object sender, EventArgs e) {if (abc == null){this.abc += this.txt_Result.Text;}else{abc = null;this.abc += this.txt_Result.Text;}}private void科学型SToolStripMenuItem_Click(object sender, EventArgs e) {Form fm2 = new Form2();fm2.Show();this.Hide();}科学型using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication6{public partial class Form2 : Form{public Form2(){InitializeComponent();}private void rBtn16_CheckedChanged(object sender, EventArgs e){this.btn_per.Enabled = false;this.btn_down.Enabled = false;this.btn_log.Enabled = false;this.btn_tan.Enabled = false;this.btn_sin.Enabled = false;this.btn_cos.Enabled = false;this.btn_Pi.Enabled = false;this.button9.Enabled = true;this.button8.Enabled = true;this.button7.Enabled = true;this.button6.Enabled = true;this.button5.Enabled = true;this.button4.Enabled = true;this.button3.Enabled = true;this.button2.Enabled = true;this.buttonA.Enabled = true;this.buttonB.Enabled = true;this.buttonC.Enabled = true;this.buttonD.Enabled = true;this.buttonE.Enabled = true;this.buttonF.Enabled = true;if (txt_Result.Text != ""){int d1;string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn8.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = a;d2 = System.Convert.ToString(d1, 8);txt_Result.Text = d2.ToString();} else if (this.rBtn10.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = a; txt_Result.Text = d1.ToString();}else if (this.rBtn2.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = a;d2 = System.Convert.ToString(d1, 2);txt_Result.Text = d2.ToString();} }}private void rBtn10_CheckedChanged(object sender, EventArgs e){this.btn_down.Enabled = false;this.btn_log.Enabled = false;this.btn_tan.Enabled = false;this.btn_sin.Enabled = false;this.btn_cos.Enabled = false;this.btn_Pi.Enabled = false;this.button9.Enabled = true;this.button8.Enabled = true;this.button7.Enabled = true;this.button6.Enabled = true;this.button5.Enabled = true;this.button4.Enabled = true;this.button3.Enabled = true;this.button2.Enabled = true;this.buttonA.Enabled = false;this.buttonB.Enabled = false;this.buttonC.Enabled = false;this.buttonD.Enabled = false;this.buttonE.Enabled = false;this.buttonF.Enabled = false;if (txt_Result.Text != ""){ int d1; string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn8.Checked){ double a = Convert.ToDouble(s1); d1 = (int)a;d2 = System.Convert.ToString(d1, 8);txt_Result.Text = d2.ToString();}else if (this.rBtn16.Checked){ double a = Convert.ToDouble(s1);d1 = (int)a; d2 = System.Convert.ToString(d1, 16); txt_Result.Text = d2.ToString();}else if (this.rBtn2.Checked){ d1 = (int)a; double a = Convert.ToDouble(s1);d2 = System.Convert.ToString(d1, 2);txt_Result.Text = d2.ToString();}}}private void rBtn8_CheckedChanged(object sender, EventArgs e){ this.btn_per.Enabled = false;this.btn_down.Enabled = false;t his.btn_log.Enabled = false;this.btn_tan.Enabled = false;this.btn_sin.Enabled = false;this.btn_cos.Enabled = false;this.btn_Pi.Enabled = false;this.button9.Enabled = false;this.button9.Enabled = false;this.button7.Enabled = true;this.button6.Enabled = true;this.button5.Enabled = true;this.button4.Enabled = true;this.button3.Enabled = true;this.button2.Enabled = true; this.buttonA.Enabled = false;this.buttonB.Enabled = false;this.buttonC.Enabled = false;this.buttonD.Enabled = false;this.buttonE.Enabled = false;this.buttonF.Enabled = false;if (txt_Result.Text != ""){int d1;string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn16.Checked){int a = System.Convert.ToInt32(s1, 8);d1 = a;d2 = System.Convert.ToString(d1, 16);txt_Result.Text = d2.ToString();}else if (this.rBtn10.Checked){int a = System.Convert.ToInt32(s1, 8);d1 = a;txt_Result.Text = d1.ToString();}else if (this.rBtn2.Checked){ int a = System.Convert.ToInt32(s1, 8);d1 = a;d2 = System.Convert.ToString(d1, 2); txt_Result.Text = d2.ToString();}}} private void rBtn2_CheckedChanged(object sender, EventArgs e){this.btn_per.Enabled = false;this.btn_down.Enabled = false;this.btn_log.Enabled = false;this.btn_tan.Enabled = false;this.btn_sin.Enabled = false;this.btn_cos.Enabled = false;this.btn_Pi.Enabled = false;this.button9.Enabled = false;this.button8.Enabled = false;this.button7.Enabled = false;this.button6.Enabled = false;this.button5.Enabled = false;his.button4.Enabled = false;this.button3.Enabled = false;this.button2.Enabled = false;this.buttonA.Enabled = false;this.buttonB.Enabled = false;this.buttonC.Enabled = false;this.buttonD.Enabled = false;this.buttonE.Enabled = false;this.buttonF.Enabled = false;if (txt_Result.Text != ""){ int d1; string d2; string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn8.Checked){ int a = System.Convert.ToInt32(s1, 2);d1 = a; d2 = System.Convert.ToString(d1, 8);txt_Result.Text = d2.ToString(); }else if (this.rBtn10.Checked){ int a = System.Convert.ToInt32(s1, 2);d1 = a; txt_Result.Text = d1.ToString(); }else if (this.rBtn16.Checked){ int a = System.Convert.ToInt32(s1, 2); d1 = a; d2 = System.Convert.ToString(d1, 16);txt_Result.Text = d2.ToString(); }}}private void radioButton8_CheckedChanged(object sender, EventArgs e) {this.txt_Result.ForeColor = Color.Black; }private void rBtnBlue_CheckedChanged(object sender, EventArgs e){ this.txt_Result.ForeColor = Color.Blue; }private void rBtnRed_CheckedChanged(object sender, EventArgs e){ this.txt_Result.ForeColor = Color.Red; }p rivate void rBtnYellow_CheckedChanged(object sender, EventArgs e){ this.txt_Result.ForeColor = Color.Yellow;}private void button0_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button1_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button2_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button3_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button4_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button5_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button6_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button7_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button8_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; } private void button9_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonA_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonB_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonC_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonD_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonE_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void buttonF_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void btn_neg_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt);double b = -a;txt_Result.Text = b.ToString(); }private void btn_per_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt);double b = a / 100.0;txt_Result.Text = b.ToString();}private void btn_Dot_Click(object sender, EventArgs e){ Button btn = (Button)sender;txt_Result.Text += btn.Text; }private void btn_Add_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; } private void btn_Sub_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; } private void btn_mul_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; } private void btn_div_Click(object sender, EventArgs e){Button btn = (Button)sender;txt_Result.Text = txt_Result.Text + " " + btn.Text + " "; } private void btn_sqr_Click(object sender, EventArgs e){double d1;string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn2.Checked){ int a = System.Convert.ToInt32(s1, 2);d1 = System.Math.Sqrt((double)a);d2 = System.Convert.ToString((int)d1, 2);txt_Result.Text = d2.ToString();}else if (this.rBtn8.Checked){int a = System.Convert.ToInt32(s1, 8);d1 = System.Math.Sqrt((double)a);d2 = System.Convert.ToString((int)d1, 8);txt_Result.Text = d2.ToString();}else if (this.rBtn16.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = System.Math.Sqrt((double)a);d2 = System.Convert.ToString((int)d1, 16);txt_Result.Text = d2.ToString();}else{double a = Convert.ToDouble(s1);d1 = System.Math.Sqrt(a);txt_Result.Text = d1.ToString();} }private void btn_ln_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt);double en = 2.718281828;double b = System.Math.Log(en, a);txt_Result.Text = b.ToString(); }private void btn_log_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt);double b = System.Math.Log10(a);txt_Result.Text = b.ToString(); }private void btn_down_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt); if (a == 0) throw new ApplicationException();double b = 1 / a;txt_Result.Text = b.ToString();private void btn_Pi_Click(object sender, EventArgs e){double pi = 3.1415926535;txt_Result.Text = pi.ToString(); }private void btn_x2_Click(object sender, EventArgs e){ int d1;string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0);if (this.rBtn2.Checked){int a = System.Convert.ToInt32(s1, 2);d1 = a * a;d2 = System.Convert.ToString(d1, 2);txt_Result.Text = d2.ToString();}else if (this.rBtn8.Checked){int a = System.Convert.ToInt32(s1, 8);d1 = a * a;d2 = System.Convert.ToString(d1, 8); txt_Result.Text = d2.ToString(); } else if (this.rBtn16.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = a * a;d2 = System.Convert.ToString(d1, 16);txt_Result.Text = d2.ToString();}else{double a = Convert.ToDouble(s1);d1 = (int)a * (int)a;txt_Result.Text = d1.ToString();} }private void btn_x3_Click(object sender, EventArgs e){int d1;string d2;string s_txt = txt_Result.Text;string s1 = s_txt.Substring(0); if (this.rBtn2.Checked){int a = System.Convert.ToInt32(s1, 2);d1 = a * a * a;d2 = System.Convert.ToString(d1, 2);txt_Result.Text = d2.ToString();}else if (this.rBtn8.Checked){int a = System.Convert.ToInt32(s1, 8);d1 = a * a * a;d2 = System.Convert.ToString(d1, 8);txt_Result.Text = d2.ToString();}else if (this.rBtn16.Checked){int a = System.Convert.ToInt32(s1, 16);d1 = a * a *a;d2 = System.Convert.ToString(d1, 16);txt_Result.Text = d2.ToString();}else{double a = Convert.ToDouble(s1);d1 = (int)a * (int)a * (int)a;txt_Result.Text = d1.ToString();}}private void btn_Clear_Click(object sender, EventArgs e){txt_Result.Text = ""; }private void btn_sin_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt); double b = System.Math.Sin(a);txt_Result.Text = b.ToString();}private void btn_cos_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt);double b = System.Math.Cos(a);txt_Result.Text = b.ToString(); }private void btn_tan_Click(object sender, EventArgs e){string s_txt = txt_Result.Text;double a = Convert.ToDouble(s_txt); double b = System.Math.Tan(a);txt_Result.Text = b.ToString();}private void btn_Back_Click(object sender, EventArgs e){this.txt_Result.Text =this.txt_Result.Text.Substring(0, this.txt_Result.Text.Length - 1);if (this.txt_Result.Text == " "){this.txt_Result.Text = “} }private void btn_Result_Click(object sender, EventArgs e){int d1;string d2;string s_txt = txt_Result.Text;int space = s_txt.IndexOf(' ');string s1 = s_txt.Substring(0, space).Trim();char opration = Convert.ToChar(s_txt.Substring((space + 1), 1));string s2 = s_txt.Substring(space + 3);{ int i = Convert.ToInt32(s1);int j = Convert.ToInt32(s2);switch (opration){case'+':d1 = i + j;break;case'-':d1 = i - j;break;case'*':d1 = i * j;break;case'/':if (j == 0){ throw new ApplicationException();}else{d1 = i/ j;}break;default:throw new ApplicationException();}txt_Result.Text = d1.ToString();}if (this.rBtn8.Checked){int i = System.Convert.ToInt32(s1, 8); int j = System.Convert.ToInt32(s2, 8);switch (opration){case'+':d1 = i + j;d2 = System.Convert.ToString(d1, 8);break;case'-':d1 = i - j;d2 = System.Convert.ToString(d1, 8);break;case'*':d1 = i * j;d2 = System.Convert.ToString(d1, 8);break;case'/':if (j == 0){throw new ApplicationException(); }else{d1 = i / j;d2 = System.Convert.ToString(d1, 8);}break;default:throw new ApplicationException();}txt_Result.Text = d2;}if (this.rBtn16.Checked){int i = System.Convert.ToInt32(s1, 16);int j = System.Convert.ToInt32(s2, 16); switch (opration){case'+':d1 = i + j;d2 = System.Convert.ToString(d1, 16);break;case'-':d1 = i – j;d2 = System.Convert.ToString(d1, 16); break;case'*':d1 = i * j;d2 = System.Convert.ToString(d1, 16);break;case'/':if (j == 0){throw new ApplicationException();}else{d1 = i / j;d2 = System.Convert.ToString(d1, 16);}break;default:throw new ApplicationException();}txt_Result.Text = d2;}if (this.rBtn2.Checked){int i = System.Convert.ToInt32(s1, 2);int j = System.Convert.ToInt32(s2, 2);switch (opration){case'+':d1 = i + j;d2 = System.Convert.ToString(d1, 2);break;case'-':d1 = i - j;d2 = System.Convert.ToString(d1, 2);break;case'*':d1 = i * j;d2 = System.Convert.ToString(d1, 2);break;case'/':if (j == 0){throw new ApplicationException();}else{d1 = i / j;d2 = System.Convert.ToString(d1, 2);}break;default;throw new ApplicationException(); }txt_Result.Text = d2;}if (this.rBtn10.Checked){double d;double a1 = Convert.ToDouble(s1);double a2 = Convert.ToDouble(s2);switch (opration){case'+':d = a1 + a2;break;case'-':d = a1 - a2;break;case'*':d = a1 * a2;break;case'/':if (a2 == 0){throw new ApplicationException();}else{d = a1 / a2;}break;default:throw new ApplicationException();}txt_Result.Text = d.ToString();}}private void标准型ToolStripMenuItem_Click(object sender, EventArgs e){Form fm1 = new Form1();fm1.Show();this.Hide();}private void帮ã?助¨²ToolStripMenuItem_Click(object sender, EventArgs e){MessageBox.Show("这是一个仿照windows的计算器应用程序,功能虽然不齐但基本能运行”);}}}六实验总结通过简易计算器这一程序的开发。