- 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 calculator
- {
- public partial class Form1 : Form
- {
- Boolean IsAOrB = true;
-
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Sin(InputNumber / 57.2957);
- OutputBox.Text = Result.ToString();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Cos(InputNumber / 57.2957);
- OutputBox.Text = Result.ToString();
- // OutputBox.Text = "1111111";
- }
- private void button3_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Tan(InputNumber / 57.2957);
- OutputBox.Text = Result.ToString();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Log(InputNumber);
- OutputBox.Text = Result.ToString();
- }
- private void button5_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Sqrt(InputNumber);
- OutputBox.Text = Result.ToString();
- }
- private void button6_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Pow(InputNumber, 2);
- OutputBox.Text = Result.ToString();
- }
- private void button7_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Log10(InputNumber);
- OutputBox.Text = Result.ToString();
- }
- private void button8_Click(object sender, EventArgs e)
- {
- Double a, b, Result;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- Result = Math.Pow(a, b);
- OutputBox.Text = Result.ToString();
- }
- private void button9_Click(object sender, EventArgs e)
- {
- Double InputNumber, Result;
- InputNumber = Convert.ToDouble(InputA.Text);
- Result = Math.Exp(InputNumber);
- OutputBox.Text = Result.ToString();
- }
- private void NumberButton1_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "1";
- else
- InputB.Text += "1";
- }
- private void NumberButton2_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "2";
- else
- InputB.Text += "2";
- }
- private void NumberButton3_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "3";
- else
- InputB.Text += "3";
- }
- private void NumberButton4_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "4";
- else
- InputB.Text += "4";
- }
- private void NumberButton5_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "5";
- else
- InputB.Text += "5";
- }
- private void NumberButton6_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "6";
- else
- InputB.Text += "6";
- }
- private void NumberButton7_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "7";
- else
- InputB.Text += "7";
- }
- private void button16_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "8";
- else
- InputB.Text += "8";
- }
- private void button17_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "9";
- else
- InputB.Text += "9";
- }
- private void button19_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += "0";
- else
- InputB.Text += "0";
- }
- private void button10_Click(object sender, EventArgs e)
- {
- if (IsAOrB == true)
- InputA.Text += ".";
- else
- InputB.Text += ".";
- }
- private void InputA_MouseClick(object sender, MouseEventArgs e)
- {
- IsAOrB = true;
- }
- private void InputB_MouseClick(object sender, MouseEventArgs e)
- {
- IsAOrB = false;
- }
- private void PlusButton_Click(object sender, EventArgs e)
- {
- Double a, b, Result;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- Result = a + b;
- OutputBox.Text = Result.ToString();
- }
- private void JianButton_Click(object sender, EventArgs e)
- {
- Double a, b, Result;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- Result = a - b;
- OutputBox.Text = Result.ToString();
- }
- private void ChengButton_Click(object sender, EventArgs e)
- {
- Double a, b, Result;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- Result = a * b;
- OutputBox.Text = Result.ToString();
- }
- private void ChuButton_Click(object sender, EventArgs e)
- {
- Double a, b, Result;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- Result = a / b;
- OutputBox.Text = Result.ToString();
- }
- private void ClearButton_Click(object sender, EventArgs e)
- {
- InputA.Text = "";
- InputB.Text = "";
- OutputBox.Text = "";
- }
- private void Max1Button_Click(object sender, EventArgs e)
- {
- double a = 0, b = 0;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- double Result;
- Result = Max(a, b);
- OutputBox.Text = "a, b最大值是:" + Result.ToString();
- }
- private void Max2Button_Click(object sender, EventArgs e)
- {
- double a = 0, b = 0, c = 0, d = 0;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- c = Convert.ToDouble(InputC.Text);
- d = Convert.ToDouble(InputD.Text);
- double Result;
- Result = Max(a, b, c);
- OutputBox.Text = "a, b, c最大值是:" + Result.ToString();
- }
- private void Max3Button_Click(object sender, EventArgs e)
- {
- double a = 0, b = 0, c = 0, d = 0;
- a = Convert.ToDouble(InputA.Text);
- b = Convert.ToDouble(InputB.Text);
- c = Convert.ToDouble(InputC.Text);
- d = Convert.ToDouble(InputD.Text);
- double Result;
- Result = Max(a, b, c, d);
- OutputBox.Text = "a, b, c, d最大值是:" + Result.ToString();
- }
- public double Max(double a, double b)
- {
- if (a > b)
- return a;
- else
- return b;
- }
- public double Max(double a, double b, double c)
- {
- double temp = a;
- if (b > temp)
- temp = b;
- if (c > temp)
- temp = c;
- return temp;
- }
- public double Max(double a, double b, double c, double d)
- {
- double temp = a;
- if (b > temp)
- temp = b;
- if (c > temp)
- temp = c;
- if (d > temp)
- temp = d;
- return temp;
- }
- }
- }
- }
09-13 00:00