Hello,
i wrote a code for calculating user input,
when ever the user input two "1+2=3"
the result is "3" which is correct .
When the then user want to use that same result to
get another result "+ 5"=8,
but the result will be =6. which is wrong.
so can someone help me out here please
Thanks.
double Operand=0;
String currentOp="";
double operand2=0;
bool iscurrentOperand;
private void btnNumeric_Click(object sender,EventArgs e)
{
Button button=(Button)sender;
txtSow.Text+=button.Text;
iscurrentOp=true;
}
private void btnOperations_Click(object sender,EventArgs e)
if (Operand!=0){
operand2=double.Parse(txtSow.Text);
switch(currentOp){
case "+":
txtSow.Text=(Operand + operand2).ToString();
break;
case "-":
txtSow.Text=(Operand- operand2).ToString();
case "*":
txtSow.Text=(Operand * operand2).ToString();
else{
currentOp=button.Text
Operand=Convert.ToDouble(txtSow.Text);
private void btnEqual_Click(object sender,EventArgs e)
switch(currentOp)
case "+"
txtSow.Text=(Operand + double.Parse(txSow.Text)).ToString();
case "-"
txtSow.Text=(Operand - double.Parse(txSow.Text)).ToString();
case "*"
txtSow.Text=(Operand * double.Parse(txSow.Text)).ToString();
case "/"
txtSow.Text=(Operand / double.Parse(txSow.Text)).ToString();