Question: Add memory capability to your calculator. Add 2 new components to the Calculator. Add a Label and another Button. Leave the Label blank, and put

Add memory capability to your calculator. Add 2 new components to the Calculator. Add a Label and another Button. Leave the Label blank, and put an M on the Button. When the user clicks the M button, the contents of the Answer TextBox should be copied to a memory variable. Also make it so that when the user moves the mouse over the label, the value in the memory variable will appear in this label, and then disappear, when the mouse moves away from the label. Also add one more button, an M+ button. When the user clicks this button, the contents of the Results box will be added to Memory. You will need to use a Global Variable to store this data.
Here is my code so far
namespace SimpleCalculator
{
public partial class SimpleCalculator: UserControl
{
public SimpleCalculator()
{
InitializeComponent();
}
private void ExitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void additionRadioButton_CheckedChanged(object sender, EventArgs e)
{
}
private void CalculateButton_Click(object sender, EventArgs e)
{
double num1, num2, result;
if (double.TryParse(number1Textbox.Text, out num1) && double.TryParse(number2Textbox.Text, out num2))
{
if (additionRadioButton.Checked)
{
result = num1+ num2;
}
else if (subtractionRadioButton.Checked)
{
result = num1- num2;
}
else if (multiplicationRadioButton.Checked)
{
result = num1* num2;
}
else if (divisionRadioButton.Checked)
{
if (num2!=0)
{
result = num1/ num2;
}
else
{
MessageBox.Show("Division by zero is not allowed.");
return;
}
}
else
{
MessageBox.Show("Please select an operation.");
return;
}
resultTextbox.Text = result.ToString();
}
else
{
MessageBox.Show("Invalid input. Please enter valid numbers.");
}
}
private void ClearButton_Click(object sender, EventArgs e)
{
number1Textbox.Clear();
number2Textbox.Clear();
resultTextbox.Clear();
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
number1Textbox.Clear();
number2Textbox.Clear();
resultTextbox.Clear();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void colorToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog colorDialog = new ColorDialog();
if (colorDialog.ShowDialog()== DialogResult.OK)
{
this.BackColor = colorDialog.Color;
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("This is an about textbox. Making this calculator was difficult but fun!");
}
private void fileMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void ForLoopButton_Click(object sender, EventArgs e)
{
for (int i =0; i <10; i++)
{
Console.WriteLine("Go Falcons!");
}
}
private void WhileLoopButton_Click(object sender, EventArgs e)
{
int i =0;
while (i <10)
{
Console.WriteLine("Go Falcons!");
i++;
}
}
private void MButton_Click(object sender, EventArgs e)
{
}
private void memoryLabel_MouseEnter(object sender, EventArgs e)
{
}
private void memoryLabel_MouseLeave(object sender, EventArgs e)
{
}
private void MPlusButton_Click(object sender, EventArgs e)
{
}
private void SimpleCalculator_Load(object sender, EventArgs e)
{
}
private void memoryLabel_Click(object sender, EventArgs e)
{
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!