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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double total1 = 0;
double total2 = 0;
private void btnOne_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnOne.Text;
}
private void btnTwo_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnTwo.Text;
}
private void bynThree_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnThree.Text;
}
private void btnFour_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnFour.Text;
}
private void btnFive_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnFive.Text;
}
private void btnSix_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnSix.Text;
}
private void btnSeven_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnSeven.Text;
}
private void btnEight_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnEight.Text;
}
private void btnNine_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnNine.Text;
}
private void bynZero_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnZero.Text;
}
private void btnClear_Click(object sender, EventArgs e)
{
txtDisplay.Clear();
}
private void btnPlus_Click(object sender, EventArgs e)
{
total1 += double.Parse(txtDisplay.Text);
txtDisplay.Clear();
plusButtonClicked = true;
minusButtonClicked = false;
}
private void btnEqual_Click(object sender, EventArgs e)
{
if (plusButtonClicked == true)
{
total2 = total1 + double.Parse(txtDisplay.Text);
}
else if (minusButtonClicked == true)
{
total2 = total1 - double.Parse(txtDisplay.Text);
}
else if (multiButtonClicked == true)
{
total2 = total1 * double.Parse(txtDisplay.Text);
}
else if (divideButtonClicked == true)
{
total2 = total1 / double.Parse(txtDisplay.Text);
}
txtDisplay.Text = total2.ToString();
total1 = 0;
}
private void btnDot_Click(object sender, EventArgs e)
{
txtDisplay.Text = txtDisplay.Text + btnDot.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
}
bool plusButtonClicked = false;
bool minusButtonClicked = false;
bool multiButtonClicked = false;
bool divideButtonClicked = false;
private void btnMultiply_Click(object sender, EventArgs e)
{
total1 += double.Parse(txtDisplay.Text);
txtDisplay.Clear();
multiButtonClicked = true;
}
private void btnMinus_Click(object sender, EventArgs e)
{
total1 += double.Parse(txtDisplay.Text);
txtDisplay.Clear();
plusButtonClicked = false;
minusButtonClicked = true;
}
private void btnDivide_Click(object sender, EventArgs e)
{
total1 += double.Parse(txtDisplay.Text);
txtDisplay.Clear();
divideButtonClicked = true;
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void txtDisplay_TextChanged(object sender, EventArgs e)
{
}
}
}
Sunday, January 1, 2012
Calculator using .NET c#
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment