CALCULATOR APPLICATION Form1.cs 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 CR public partial class Calculator : Form bool plus = false; bool minus = false; bool divide = false; bool multiply = false;
bool equal = false; public Calculator() InitializeComponent(); private void btn1_click(object sender, EventArgs e) checkwhetherequal(); abc(); txtresult.text = txtresult.text + "1"; private void abc() // throw new NotImplementedException(); private void checkwhetherequal() if (equal) equal = false; //throw new NotImplementedException(); private void CheckIfEqual() //throw new NotImplementedException(); if (equal) equal = false; private void btn0_click(object sender, EventArgs e)
txtresult.text = txtresult.text + "0"; private void btn2_click(object sender, EventArgs e) txtresult.text = txtresult.text + "2"; private void btn3_click(object sender, EventArgs e) txtresult.text = txtresult.text + "3"; private void btn4_click(object sender, EventArgs e) txtresult.text = txtresult.text + "4"; private void btn5_click(object sender, EventArgs e) txtresult.text = txtresult.text + "5"; private void btn6_click(object sender, EventArgs e) txtresult.text = txtresult.text + "6"; private void btn7_click(object sender, EventArgs e) txtresult.text = txtresult.text + "7"; private void btn8_click(object sender, EventArgs e) txtresult.text = txtresult.text + "8";
private void btn9_click(object sender, EventArgs e) txtresult.text = txtresult.text + "9"; private void btnpoint_click(object sender, EventArgs e) if (txtresult.text.contains(".")) txtresult.text = txtresult.text + "."; private void btnplus_click(object sender, EventArgs e) if (txtresult.text == "") plus = true; txtresult.tag = txtresult.text; private void btnequals_click(object sender, EventArgs e) //int i = 9; //double d; //d = Math.Sqrt(i); //MessageBox.Show(d.ToString()); equal = true;
if (plus) decimal dec = Convert.ToDecimal(txtResult.Tag) + Convert.ToDecimal(txtResult.Text); txtresult.text = dec.tostring(); if (minus) decimal dec = Convert.ToDecimal(txtResult.Tag) - Convert.ToDecimal(txtResult.Text); txtresult.text = dec.tostring(); if (divide) decimal dec = Convert.ToDecimal(txtResult.Tag) / Convert.ToDecimal(txtResult.Text); txtresult.text = dec.tostring(); if (multiply) decimal dec = Convert.ToDecimal(txtResult.Tag) * Convert.ToDecimal(txtResult.Text); txtresult.text = dec.tostring(); private void btnminus_click(object sender, EventArgs e) if (txtresult.text == "") minus = true; txtresult.tag = txtresult.text; private void btndiv_click(object sender, EventArgs e) if (txtresult.text == "")
divide = true; txtresult.tag = txtresult.text; private void btnmul_click(object sender, EventArgs e) if (txtresult.text == "") multiply = true; txtresult.tag = txtresult.text; private void btnclear_click(object sender, EventArgs e) plus = minus = divide = multiply = false; txtresult.tag = ""; private void Calculator_Load(object sender, EventArgs e) //private void button1_click(object sender, EventArgs e) // // System.String s; // System.Text.StringBuilder s1;
// MessageBox.Show(typeof(string).ToString()); // //private void button1_click(object sender, EventArgs e) // // string s = "ashish"; // bool i=s // MessageBox.Show(s.GetType()); //
PROGRAM.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace CR static class Program /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Calculator());