You are on page 1of 5

using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Text; System.Windows.Forms;

namespace WindowsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool bool bool bool bool plus = false; minus = false; multiply = false; divide = false; equal = false;

private void button1_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "1"; } private void Checkif() { if (equal) { textBox1.Text = ""; equal = false; } } private void button2_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "2"; } private void button3_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "3"; } private void button4_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "4"; } private void button5_Click(object sender, EventArgs e)

{ Checkif(); textBox1.Text = textBox1.Text + "5"; } private void button6_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "6"; } private void button7_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "7"; } private void button8_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "8"; } private void button9_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "9"; } private void button0_Click(object sender, EventArgs e) { Checkif(); textBox1.Text = textBox1.Text + "0"; } private void buttondecimal_Click(object sender, EventArgs e) { if (textBox1.Text.Contains(".")) { return; } else { textBox1.Text = textBox1.Text + "."; } } private void buttonplusminus_Click(object sender, EventArgs e) { if (textBox1.Text.Contains("-")) { textBox1.Text = textBox1.Text.Remove(0, 1); } else { textBox1.Text = "-" + textBox1.Text; } } private void buttonadd_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } else {

plus = true; textBox1.Tag = textBox1.Text; textBox1.Text = ""; } } private void buttonminus_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } else { minus = true; textBox1.Tag = textBox1.Text; textBox1.Text = ""; } } private void buttonmultiply_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } else { multiply = true; textBox1.Tag = textBox1.Text; textBox1.Text = ""; } } private void buttondivide_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } else { divide = true; textBox1.Tag = textBox1.Text; textBox1.Text = ""; } } private void buttonequal_Click(object sender, EventArgs e) { equal = true; if (plus) { decimal ans = Convert.ToDecimal(textBox1.Tag) + Convert.ToDecimal(textBox1.Text); textBox1.Text = ans.ToString(); } if (minus) { decimal ans = Convert.ToDecimal(textBox1.Tag) Convert.ToDecimal(textBox1.Text); textBox1.Text = ans.ToString(); }

if (multiply) { decimal ans = Convert.ToDecimal(textBox1.Tag) * Convert.ToDecimal(textBox1.Text); textBox1.Text = ans.ToString(); } if (divide) { decimal ans = Convert.ToDecimal(textBox1.Tag) / Convert.ToDecimal(textBox1.Text); textBox1.Text = ans.ToString(); } } private void buttonclear_Click(object sender, EventArgs e) { plus = multiply = divide = minus = false; textBox1.Text = ""; textBox1.Tag = ""; } private void sinebutton_Click(object sender, EventArgs e) { double theta; theta = Math.Sin((Convert.ToDouble(textBox1.Text))*Math.PI/180); textBox1.Text = theta.ToString(); } private void cosbutton_Click(object sender, EventArgs e) { double theta; theta = Math.Cos((Convert.ToDouble(textBox1.Text))*Math.PI/180); textBox1.Text = theta.ToString(); } private void tanbutton_Click(object sender, EventArgs e) { double theta; theta = Math.Tan((Convert.ToDouble(textBox1.Text))*Math.PI/180); textBox1.Text = theta.ToString(); } private void sqrtbutton_Click(object sender, EventArgs e) { double theta; theta = Math.Sqrt(Convert.ToDouble(textBox1.Text)); textBox1.Text = theta.ToString(); } private void absbutton_Click(object sender, EventArgs e) { double theta; theta = Math.Abs(Convert.ToDouble(textBox1.Text)); textBox1.Text = theta.ToString(); } private void ceilingbutton_Click(object sender, EventArgs e)

{ double theta; theta = Math.Ceiling(Convert.ToDouble(textBox1.Text)); textBox1.Text = theta.ToString(); } } }

You might also like