C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一元运算:输入数

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 22:01:05
C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一

C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一元运算:输入数
C#编写简单计算器
简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一元运算:输入数据后点击运算符sqrt即计算数的平方根.对于二元运算:通过点击数字按钮进行数字的输入,在输入一个数据后,点击操作符号按钮(如+,-,*,/)后,再输入一个数据将进行相应的运算

C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一元运算:输入数
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace jisuan
{
///
/// Form1 的摘要说明.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
///
/// 必需的设计器变量.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容.
///
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(24, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 0;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(312, 72);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 1;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(448, 72);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(88, 21);
this.textBox3.TabIndex = 2;
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"+",
"-",
"*",
"/"});
this.comboBox1.Location = new System.Drawing.Point(152, 72);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 3;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(64, 184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(104, 32);
this.button1.TabIndex = 4;
this.button1.Text = "计算";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(216, 192);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 5;
this.button2.Text = "清除";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(376, 192);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 6;
this.button3.Text = "退出";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(656, 366);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
///
/// 应用程序的主入口点.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public double jia(double a,double b)
{
return a+b;
}
public double jian(double a,double b)
{
return a-b;
}
public double cheng(double a,double b)
{
return a*b;
}
public double chu(double a,double b)
{
return a/b;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
string i=this.comboBox1.SelectedItem.ToString();
switch(i)
{

case "+":this.textBox3.Text=this.jia(double.Parse(this.textBox1.Text),double.Parse(this.textBox2.Text)).ToString();

break;
case "-":this.textBox3.Text=this.jian(double.Parse(this.textBox1.Text),double.Parse(this.textBox2.Text)).ToString();
break;
case "*":this.textBox3.Text=this.cheng(double.Parse(this.textBox1.Text),double.Parse(this.textBox2.Text)).ToString();
break;
case"/" :this.textBox3.Text=this.chu(double.Parse(this.textBox1.Text),double.Parse(this.textBox2.Text)).ToString();
break;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
this.textBox1.Text=null;
this.textBox2.Text=null;
this.textBox3.Text = null;
}
private void button3_Click(object sender, EventArgs e)
{

//this.Hide();
Application.Exit();
//this.Close();

}
}
}

C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+,-,*,/,^(乘方)是二元运算(需要2个操作数),sqrt为一元运算.对于一元运算:输入数 如何用C#制作简单的计算器,思路是什么啊 用JAVA编写一个计算器完成简单的加法、减法、除法和乘法操作.RT 用C#编写一个简单的计算器,只含有加减乘除四则运算,怎么处理被除数不能为零的异常呢 怎么样用简单的计算器计算标准差 设计具有简单四则运算功能的计算器. 一元稀疏多项式简单的计算器 如何用vc++编写一个简单的(只有加减乘除)计算器程序? 用java编写计算器 能够实现简单的加、减、乘、除、乘方、开方运算等; 设计一个简单的计算器,完成两个数的加减乘除.c语言题 求一C++编写的计算器,要求能运算简单的四则运算,并且包括括号和小数! c语言计算器程序设计包含加减乘除简单的函数运算 谁可以简单解释一下计算器的工作原理? 怎么用科学计算器简单的计算方差均值 如何用C#编写简易计算器 根据图 设计一个能够完成加、减、乘、除、取余等运算的简单计算器. 使用C#程序编写一个能求解由+、-、*、/、(、)构成的混合表达式运算的简单计算器程序.要完整可实现的程序代码,打包后发邮箱[email protected].急用,这门课程我学的不好,请尽量准确点. C#三角形面积计算器看有高手以前用C#语言做过简单三角形面积计算器吗?当两条边不构成三角形事会抛出提示.可以把代码放上给小弟弟吗?就是按照这样图片这样做