Microsoft
Software
Hardware
Network
Question : Help Please!
This is the question:
develop a basic calculator that operates on real numbers. The Graphical User Interface
I HAVE DONE ALL THE WORK AND MY CALCULATOR WORKS FINE EXCEPT FOR THIS PART BELOW :
Your calculator's behavior should pretty much behave like the Windows Calculator in Standard mode. In Standard mode, the order that operations are evaluated is that in which they are entered. For example, if the users presses "3", "+", "2", and "*", the display gets the value of the first operation (3+2). Subsequently pressing "4" and "=" results in the running total (4) getting multiplied by 4, yielding 20. If multiple operators are input in succession, use the last one for computation.
CAN SOMEONE PLEASE HELP ME! THIS IS MY CODE:
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 Calculator
{
public partial class calculatorForm : Form
{
bool add = false;
bool sub = false;
bool multiply = false;
bool divide = false;
bool equal = false;
public calculatorForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btn1_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "1";
}
private void CheckifEqual()
{
if (equal)
{
textBox1.Text = "";
equal = false;
}
}
private void btn0_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "0";
}
private void btn4_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "4";
}
private void btn7_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "7";
}
private void btm8_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "8";
}
private void btn5_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "5";
}
private void btn2_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "2";
}
private void btn3_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "3";
}
private void btn6_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "6";
}
private void btn9_Click(object sender, EventArgs e)
{
CheckifEqual();
textBox1.Text = textBox1.Text + "9";
}
private void btnDec_Click(object sender, EventArgs e)
{
CheckifEqual();
if (textBox1.Text.Contains(".
"))
{
return;
}
else
{
textBox1.Text = textBox1.Text + ".";
}
}
private void btnPlusMinus_Click(object sender, EventArgs e)
{
if (textBox1.Text.Contains("-
"))
{
textBox1.Text = textBox1.Text.Remove(0, 1);
}
else
{
textBox1.Text = "-" + textBox1.Text;
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
add = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void btnEqual_Click(object sender, EventArgs e)
{
equal = true;
if (add)
{
decimal dec = Convert.ToDecimal(textBox1
.Tag) + Convert.ToDecimal(textBox1
.Text);
textBox1.Text = dec.ToString();
}
if (multiply)
{
decimal dec = Convert.ToDecimal(textBox1
.Tag) * Convert.ToDecimal(textBox1
.Text);
textBox1.Text = dec.ToString();
}
if (sub)
{
decimal dec = Convert.ToDecimal(textBox1
.Tag) - Convert.ToDecimal(textBox1
.Text);
textBox1.Text = dec.ToString();
}
if (divide)
{
decimal dec = Convert.ToDecimal(textBox1
.Tag) / Convert.ToDecimal(textBox1
.Text);
textBox1.Text = dec.ToString();
}
}
private void btnSub_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
sub = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void btnMultiply_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
multiply = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void btnDivide_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
return;
}
else
{
divide = true;
textBox1.Tag = textBox1.Text;
textBox1.Text = "";
}
}
private void btnClear_Click(object sender, EventArgs e)
{
add = sub = multiply = divide = equal = false;
textBox1.Text = "";
textBox1.Tag = "";
}
Answer : Help Please!
You have an extra } just above that method and you have a } missing at the end. You may have inserted your code between the wrong pair of }s.
Random Solutions
Problem with autodiscover with Outlook 2007/Exchange 2003
How to ensure only one user at a time uses the MS access application?
Remove Webroot Spy Sweeper 3.1
Cannot boot into Windows 7 partition (Blinking cursor) after using Acronis Disk Director resize
VMware, vSphere Virtual Machine and Disk Errors "invalid disk type 7" and "cannot detect guest operating system type"
How to map external ip to internal subnet on a Cisco ASA
Corrupt Windows\System32\Config\Sy
stem
Powershell, get-qadcompter
"All circuits are busy" message received randomly when dialing out from Trixbox 2.8.
MailChimp WordPress Plugin Embedded styles display: none; hiding form, Part 2