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
XP Mode - usb software key not working
Secure Email for HIPAA compliance
I'm trying to config route and vpn in Ubuntu
Installing Small Business Server 2008 trail
css easy question - page items apprearing low down
How to connect treeview & listview or grid through Access database
Prevent users from sending emails to all users group lotus notes
How to configure Active Sync in Exchange 2003 and iPhone 3GS
ghost 14 in windows xp is requiring me to run in windows recovery enviroment
How do I hide site tabs from certain users?