1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. namespace calculator
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         Boolean IsAOrB = true;
  14.  
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }

  19.         private void button1_Click(object sender, EventArgs e)
  20.         {
  21.             Double InputNumber, Result;

  22.             InputNumber = Convert.ToDouble(InputA.Text);
  23.             Result = Math.Sin(InputNumber / 57.2957);
  24.             OutputBox.Text = Result.ToString();

  25.         }

  26.         private void button2_Click(object sender, EventArgs e)
  27.         {
  28.             Double InputNumber, Result;

  29.             InputNumber = Convert.ToDouble(InputA.Text);
  30.             Result = Math.Cos(InputNumber / 57.2957);
  31.             OutputBox.Text = Result.ToString();
  32.            // OutputBox.Text = "1111111";
  33.         }

  34.         private void button3_Click(object sender, EventArgs e)
  35.         {
  36.             Double InputNumber, Result;

  37.             InputNumber = Convert.ToDouble(InputA.Text);
  38.             Result = Math.Tan(InputNumber / 57.2957);
  39.             OutputBox.Text = Result.ToString();
  40.         }

  41.         private void button4_Click(object sender, EventArgs e)
  42.         {
  43.             Double InputNumber, Result;

  44.             InputNumber = Convert.ToDouble(InputA.Text);
  45.             Result = Math.Log(InputNumber);
  46.             OutputBox.Text = Result.ToString();
  47.         }

  48.         private void button5_Click(object sender, EventArgs e)
  49.         {
  50.             Double InputNumber, Result;

  51.             InputNumber = Convert.ToDouble(InputA.Text);
  52.             Result = Math.Sqrt(InputNumber);
  53.             OutputBox.Text = Result.ToString();
  54.         }

  55.         private void button6_Click(object sender, EventArgs e)
  56.         {
  57.             Double InputNumber, Result;

  58.             InputNumber = Convert.ToDouble(InputA.Text);
  59.             Result = Math.Pow(InputNumber, 2);
  60.             OutputBox.Text = Result.ToString();
  61.         }

  62.         private void button7_Click(object sender, EventArgs e)
  63.         {
  64.             Double InputNumber, Result;

  65.             InputNumber = Convert.ToDouble(InputA.Text);
  66.             Result = Math.Log10(InputNumber);
  67.             OutputBox.Text = Result.ToString();
  68.         }

  69.         private void button8_Click(object sender, EventArgs e)
  70.         {
  71.             Double a, b, Result;

  72.             a = Convert.ToDouble(InputA.Text);
  73.             b = Convert.ToDouble(InputB.Text);
  74.             Result = Math.Pow(a, b);
  75.             OutputBox.Text = Result.ToString();
  76.         }

  77.         private void button9_Click(object sender, EventArgs e)
  78.         {
  79.             Double InputNumber, Result;

  80.             InputNumber = Convert.ToDouble(InputA.Text);
  81.             Result = Math.Exp(InputNumber);
  82.             OutputBox.Text = Result.ToString();
  83.         }

  84.         private void NumberButton1_Click(object sender, EventArgs e)
  85.         {
  86.             if (IsAOrB == true)
  87.                 InputA.Text += "1";
  88.             else
  89.                 InputB.Text += "1";
  90.         }

  91.         private void NumberButton2_Click(object sender, EventArgs e)
  92.         {
  93.              if (IsAOrB == true)
  94.                  InputA.Text += "2";
  95.              else
  96.                  InputB.Text += "2";
  97.         }

  98.         private void NumberButton3_Click(object sender, EventArgs e)
  99.         {
  100.             if (IsAOrB == true)
  101.                 InputA.Text += "3";
  102.             else
  103.                 InputB.Text += "3";
  104.         }

  105.         private void NumberButton4_Click(object sender, EventArgs e)
  106.         {
  107.             if (IsAOrB == true)
  108.                 InputA.Text += "4";
  109.             else
  110.                 InputB.Text += "4";
  111.         }

  112.         private void NumberButton5_Click(object sender, EventArgs e)
  113.         {
  114.             if (IsAOrB == true)
  115.                 InputA.Text += "5";
  116.             else
  117.                 InputB.Text += "5";
  118.         }

  119.         private void NumberButton6_Click(object sender, EventArgs e)
  120.         {
  121.             if (IsAOrB == true)
  122.                 InputA.Text += "6";
  123.             else
  124.                 InputB.Text += "6";
  125.         }

  126.         private void NumberButton7_Click(object sender, EventArgs e)
  127.         {
  128.             if (IsAOrB == true)
  129.                 InputA.Text += "7";
  130.             else
  131.                 InputB.Text += "7";
  132.         }

  133.         private void button16_Click(object sender, EventArgs e)
  134.         {
  135.             if (IsAOrB == true)
  136.                 InputA.Text += "8";
  137.             else
  138.                 InputB.Text += "8";
  139.         }

  140.         private void button17_Click(object sender, EventArgs e)
  141.         {
  142.             if (IsAOrB == true)
  143.                 InputA.Text += "9";
  144.             else
  145.                 InputB.Text += "9";
  146.         }

  147.         private void button19_Click(object sender, EventArgs e)
  148.         {
  149.             if (IsAOrB == true)
  150.                 InputA.Text += "0";
  151.             else
  152.                 InputB.Text += "0";
  153.         }

  154.         private void button10_Click(object sender, EventArgs e)
  155.         {
  156.             if (IsAOrB == true)
  157.                 InputA.Text += ".";
  158.             else
  159.                 InputB.Text += ".";
  160.         }

  161.         private void InputA_MouseClick(object sender, MouseEventArgs e)
  162.         {
  163.             IsAOrB = true;
  164.         }

  165.         private void InputB_MouseClick(object sender, MouseEventArgs e)
  166.         {
  167.             IsAOrB = false;
  168.         }

  169.         private void PlusButton_Click(object sender, EventArgs e)
  170.         {
  171.             Double a, b, Result;
  172.             a = Convert.ToDouble(InputA.Text);
  173.             b = Convert.ToDouble(InputB.Text);
  174.             Result = a + b;
  175.             OutputBox.Text = Result.ToString();
  176.         }

  177.         private void JianButton_Click(object sender, EventArgs e)
  178.         {
  179.             Double a, b, Result;
  180.             a = Convert.ToDouble(InputA.Text);
  181.             b = Convert.ToDouble(InputB.Text);
  182.             Result = a - b;
  183.             OutputBox.Text = Result.ToString();
  184.         }

  185.         private void ChengButton_Click(object sender, EventArgs e)
  186.         {
  187.             Double a, b, Result;

  188.             a = Convert.ToDouble(InputA.Text);
  189.             b = Convert.ToDouble(InputB.Text);
  190.             Result = a * b;
  191.             OutputBox.Text = Result.ToString();
  192.         }

  193.         private void ChuButton_Click(object sender, EventArgs e)
  194.         {
  195.             Double a, b, Result;

  196.             a = Convert.ToDouble(InputA.Text);
  197.             b = Convert.ToDouble(InputB.Text);
  198.             Result = a / b;
  199.             OutputBox.Text = Result.ToString();
  200.         }

  201.         private void ClearButton_Click(object sender, EventArgs e)
  202.         {
  203.             InputA.Text = "";
  204.             InputB.Text = "";
  205.             OutputBox.Text = "";
  206.         }

  207.         private void Max1Button_Click(object sender, EventArgs e)
  208.         {
  209.             double a = 0, b = 0;

  210.             a = Convert.ToDouble(InputA.Text);
  211.             b = Convert.ToDouble(InputB.Text);

  212.             double Result;

  213.             Result = Max(a, b);
  214.             OutputBox.Text = "a, b最大值是:" + Result.ToString();
  215.         }

  216.         private void Max2Button_Click(object sender, EventArgs e)
  217.         {
  218.             double a = 0, b = 0, c = 0, d = 0;

  219.             a = Convert.ToDouble(InputA.Text);
  220.             b = Convert.ToDouble(InputB.Text);
  221.             c = Convert.ToDouble(InputC.Text);
  222.             d = Convert.ToDouble(InputD.Text);

  223.             double Result;

  224.             Result = Max(a, b, c);
  225.             OutputBox.Text = "a, b, c最大值是:" + Result.ToString();
  226.         }

  227.         private void Max3Button_Click(object sender, EventArgs e)
  228.         {
  229.             double a = 0, b = 0, c = 0, d = 0;

  230.             a = Convert.ToDouble(InputA.Text);
  231.             b = Convert.ToDouble(InputB.Text);
  232.             c = Convert.ToDouble(InputC.Text);
  233.             d = Convert.ToDouble(InputD.Text);

  234.             double Result;

  235.             Result = Max(a, b, c, d);
  236.             OutputBox.Text = "a, b, c, d最大值是:" + Result.ToString();
  237.         }

  238.         public double Max(double a, double b)
  239.         {
  240.             if (a > b)
  241.                 return a;

  242.             else
  243.                 return b;
  244.         }

  245.         public double Max(double a, double b, double c)
  246.         {
  247.             double temp = a;

  248.             if (b > temp)
  249.                 temp = b;

  250.             if (c > temp)
  251.                 temp = c;

  252.             return temp;
  253.         }

  254.         public double Max(double a, double b, double c, double d)
  255.         {
  256.             double temp = a;

  257.             if (b > temp)
  258.                 temp = b;

  259.             if (c > temp)
  260.                 temp = c;

  261.             if (d > temp)
  262.                 temp = d;

  263.             return temp;
  264.         }
  265.      }
  266. }
  267. }计算器-LMLPHP

计算器-LMLPHP

计算器-LMLPHP




09-13 00:00