private void equals_Click(object sender, EventArgs e) { double Result = 0; switch (sOperator) { case "+": Result = float.Parse(sFirstValue) + float.Parse(ResultText.Text); break; case "-": Result = float.Parse(sFirstValue) - float.Parse(ResultText.Text); break; case "*": Result = float.Parse(sFirstValue) * float.Parse(ResultText.Text); break; case "/": Result = float.Parse(sFirstValue) / float.Parse(ResultText.Text); break; case "sin": double val = double.Parse(sFirstValue); Result = Math.Sin(val * Math.PI / 180); break; case "cos": double ans = double.Parse(sFirstValue); Result = Math.Cos(ans * Math.PI / 180); break; case "tan": ans = double.Parse(sFirstValue); Result = Math.Tan(ans * Math.PI / 180); break; case "fact": double fact = 1; double value = double.Parse(sFirstValue); for (double i = value; i >= 1; i--) { fact = fact * i; } Result = fact; break; case "square": Result = float.Parse(sFirstValue) * float.Parse(sFirstValue); break; } ResultText.ResetText(); ResultText.Text = Convert.ToString(Result); }
private void clickAdd_Click(object sender, EventArgs e) { sFirstValue = ResultText.Text; ResultText.ResetText(); sOperator = clickAdd.Text; }
private void divide_Click(object sender, EventArgs e) { sFirstValue = ResultText.Text; ResultText.ResetText(); sOperator = divide.Text; }
private void tabButton_Click(object sender, EventArgs e) { sFirstValue = ResultText.Text; ResultText.ResetText(); sOperator = tabButton.Text; }
private void subtract_Click(object sender, EventArgs e) { sFirstValue = ResultText.Text; ResultText.ResetText(); sOperator = subtract.Text; }