SlideShare a Scribd company logo
1 of 12
Download to read offline
This is a C# project . I am expected to create as this image shows. If the image isnot clearly
showing , it's the Chegg's system. Please , if you see it quit long, assist me with the starting and
hinting bulltes point or functions that may simplify. Thannks...
The design of the Calculator form
Operation
· To clear the contents of memory, the user clicks the MC button. To save the value that’s
currently displayed in memory, the user clicks the MS button. To recall the value that’s currently
in memory and display it in the calculator, the user clicks the MR button. And to add the value
that’s currently displayed to the value in memory, the user clicks the M+ button.
· An M is displayed in the box above the MC button whenever the memory contains a value.
· See project 12-1 for additional details.
Specifications
· Create a class named MemoryCalculator that inherits the Calculator class described in
project 12-1. The MemoryCalculator class should add properties and methods as needed to
implement the memory function.
Note:
· MemoryCalculator class design:
Method Description
MemoryStore Stores the calculator’s current value in memory.
MemoryRecall Sets the calculator’s current value to the value stored in memory.
MemoryAdd Adds the calculator’s current value to the value currently stored in
memory.
MemoryClear Clears the current memory value.
Solution
Calculator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Calculator
{
public class Calculator
{
public decimal currentValue;
private decimal operand1;
public decimal operand2;
private Operator op;
public enum Operator { Addd, Subtract, Multiply, Divide, None };
//Needed to be changed from private to public
public Calculator()
{
this.currentValue = 0;
this.operand1 = 0;
this.operand2 = 0;
this.op = Operator.None;
}
public decimal CurrentValue
{
get { return this.currentValue; }
}
public void Clear()
{
this.currentValue = 0;
this.operand1 = 0;
this.operand2 = 0;
this.op = Operator.None;
}
public void Add(decimal val)
{
this.operand1 = val;
this.currentValue = val;
this.op = Operator.Addd;
}
public void Subtract(decimal val)
{
this.operand1 = val;
this.currentValue = val;
this.op = Operator.Subtract;
}
public void Multiply(decimal val)
{
this.operand1 = val;
this.currentValue = val;
this.op = Operator.Multiply;
}
public void Divide(decimal val)
{
this.operand1 = val;
this.currentValue = val;
this.op = Operator.Divide;
}
public void Equals(decimal val)
{
operand2 = val;
switch (this.op)
{
case Operator.Addd:
currentValue = operand1 + operand2;
break;
case Operator.Subtract:
currentValue = operand1 - operand2;
break;
case Operator.Multiply:
currentValue = operand1 * operand2;
break;
case Operator.Divide:
//Try catch to prevent dividing by zero
try
{
currentValue = operand1 / operand2;
}
catch (DivideByZeroException)
{
MessageBox.Show("You cannot divide by zero", "Error!");
}
break;
case Operator.None:
currentValue = operand2;
break;
}
operand1 = currentValue;
}
public void SquareRoot(decimal val)
{
this.operand1 = val;
currentValue = (decimal)Math.Sqrt(Convert.ToDouble(operand1));
op = Operator.None;
}
public void Reciprocal(decimal val)
{
this.operand1 = val;
currentValue = 1 / operand1;
op = Operator.None;
}
}
}
MemoryCalculator.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calculator
{
public class MemoryCalculator : Calculator
{
//variable to hold the memory
private static decimal memoryStorage;
private static string dispValue;
public MemoryCalculator(decimal memory)
{
this.MemoryStorage = memory;
}
//added string constructor to get the display value from form1
//this will allow me to add what ever is inputed to be added to memoryStorage
(MemoryAdd function)
public MemoryCalculator(string displayValue)
{
this.DisplayValue = displayValue;
}
public string DisplayValue
{
get
{
return dispValue;
}
set
{
dispValue = value;
}
}
public decimal MemoryStorage
{
get
{
return memoryStorage;
}
set
{
memoryStorage = value;
}
}
public decimal memoryStore()
{
//save memoryStorage
memoryStorage = this.MemoryStorage;
//going to return this to put in the txtMemory text box
return memoryStorage;
}
public decimal memoryAdd()
{
//declare array to define what numbers to add
decimal[] addens = { Convert.ToDecimal(this.DisplayValue), memoryStorage };
//add memoryStorage and current value
memoryStorage = addens.Sum();
return memoryStorage;
}
public void memoryClear()
{
//set memoryStorage to 0
memoryStorage = 0;
}
public decimal memoryRecall()
{
// return memoryStorage
return memoryStorage;
}
}
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string displayString;
//Needs to be decimal
private decimal displayValue;
private bool newValue;
private bool decimalEntered;
private Calculator Calc = new Calculator();
//define MemoryCalculator class
private MemoryCalculator calcMem = new MemoryCalculator(0);
private void Form1_Load(object sender, System.EventArgs e)
{
//Initializes values
displayValue = 0;
displayString = "";
newValue = true;
decimalEntered = false;
}
private void btnNumber_Click(object sender, System.EventArgs e)
{
if (newValue)
{
displayString = "";
newValue = false;
}
//Sends button value to textbox
displayString += ((Button)sender).Tag.ToString();
displayValue = Convert.ToDecimal(displayString);
txtDisplay.Text = displayString;
}
private void btnBackSpace_Click(object sender, System.EventArgs e)
{
if (!newValue)
{
if (displayString.Length > 1)
{
displayString = displayString.Substring(0, displayString.Length - 1);
displayValue = Convert.ToDecimal(displayString);
txtDisplay.Text = displayString;
}
else if (displayString.Length == 1)
{
displayValue = Calc.CurrentValue;
displayString = displayValue.ToString();
txtDisplay.Text = displayString;
newValue = true;
}
}
}
private void btnClear_Click(object sender, System.EventArgs e)
{
Calc.Clear();
displayString = "";
displayValue = 0;
txtDisplay.Text = displayValue.ToString();
newValue = true;
decimalEntered = false;
}
private void btnDecimal_Click(object sender, System.EventArgs e)
{
if (!decimalEntered)
{
displayString += ".";
//un-needed line of code?
//displayValue = Convert.ToInt16(displayString);
txtDisplay.Text = displayString;
decimalEntered = true;
}
else
{
MessageBox.Show("You can only input 1 decimal!", "Error!");
}
}
private void btnSign_Click(object sender, System.EventArgs e)
{
displayValue = -displayValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
Calc.Add(displayValue);
newValue = true;
decimalEntered = false;
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnSubtract_Click(object sender, System.EventArgs e)
{
Calc.Subtract(displayValue);
newValue = true;
decimalEntered = false;
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnMultiply_Click(object sender, System.EventArgs e)
{
Calc.Multiply(displayValue);
newValue = true;
decimalEntered = false;
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnDivide_Click(object sender, System.EventArgs e)
{
Calc.Divide(displayValue);
newValue = true;
decimalEntered = false;
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnSqrt_Click(object sender, System.EventArgs e)
{
Calc.SquareRoot(displayValue);
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
private void btnReciprocal_Click(object sender, System.EventArgs e)
{
try
{
Calc.Reciprocal(displayValue);
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
}
catch (DivideByZeroException)
{
displayValue = 0;
txtDisplay.Text = "Cannot divide by zero.";
newValue = true;
decimalEntered = false;
}
}
private void btnEquals_Click(object sender, System.EventArgs e)
{
if (newValue)
Calc.Equals(displayValue);
else
Calc.Equals(displayValue);
displayValue = Calc.CurrentValue;
txtDisplay.Text = displayValue.ToString();
newValue = true;
decimalEntered = false;
}
private void btnMS_Click(object sender, EventArgs e)
{
//pass displayValue to the MemoryCalculator class
calcMem = new MemoryCalculator(displayValue);
calcMem.memoryStore();
txtMemory.Text = 'M'.ToString();
}
private void btnMAdd_Click(object sender, EventArgs e)
{
calcMem = new MemoryCalculator(displayValue.ToString());
calcMem.memoryAdd();
txtMemory.Text = 'M'.ToString();
}
private void btnMC_Click(object sender, EventArgs e)
{
calcMem.memoryClear();
txtMemory.Text = ' '.ToString();
}
private void btnMR_Click(object sender, EventArgs e)
{
//store recalled memory into a variable to be used to display text, and set displayValue
text
decimal recalledMemory = calcMem.memoryRecall();
displayValue = recalledMemory;
txtDisplay.Text = (recalledMemory.ToString());
//reset memory after it is recalled
calcMem.memoryClear();
txtMemory.Text = ' '.ToString();
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Calculator
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Note: i cant able to upload Form1.Designer.cs file due to more character. we have limited to post
65,000 characters only

More Related Content

Similar to This is a C# project . I am expected to create as this image shows. .pdf

Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)RichardWarburton
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Palak Sanghani
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonfNataliya Patsovska
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTVasil Remeniuk
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsEvangelia Mitsopoulou
 
BLoC - Be Reactive in flutter
BLoC - Be Reactive in flutterBLoC - Be Reactive in flutter
BLoC - Be Reactive in flutterGiacomo Ranieri
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answersQuratulain Naqvi
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfcalderoncasto9163
 
A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014Matthias Noback
 
Tool Development 07 - Undo & Redo, Drag & Drop
Tool Development 07 - Undo & Redo, Drag & DropTool Development 07 - Undo & Redo, Drag & Drop
Tool Development 07 - Undo & Redo, Drag & DropNick Pruehs
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react applicationGreg Bergé
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfforwardcom41
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS ProgrammersDavid Rodenas
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6Nitay Neeman
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2Warui Maina
 

Similar to This is a C# project . I am expected to create as this image shows. .pdf (20)

Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)Pragmatic functional refactoring with java 8 (1)
Pragmatic functional refactoring with java 8 (1)
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Day 5
Day 5Day 5
Day 5
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 
Functional C++
Functional C++Functional C++
Functional C++
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWT
 
Battle of React State Managers in frontend applications
Battle of React State Managers in frontend applicationsBattle of React State Managers in frontend applications
Battle of React State Managers in frontend applications
 
BLoC - Be Reactive in flutter
BLoC - Be Reactive in flutterBLoC - Be Reactive in flutter
BLoC - Be Reactive in flutter
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdfJAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
JAVA...With N.E.T_B.E.A.N.S___________________________________.pdf
 
A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014
 
Tool Development 07 - Undo & Redo, Drag & Drop
Tool Development 07 - Undo & Redo, Drag & DropTool Development 07 - Undo & Redo, Drag & Drop
Tool Development 07 - Undo & Redo, Drag & Drop
 
Recompacting your react application
Recompacting your react applicationRecompacting your react application
Recompacting your react application
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
 
Redux for ReactJS Programmers
Redux for ReactJS ProgrammersRedux for ReactJS Programmers
Redux for ReactJS Programmers
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
 
React hooks
React hooksReact hooks
React hooks
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 

More from indiaartz

Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdf
Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdfSome Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdf
Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdfindiaartz
 
Simplify and write the answer with positive exponents Simplify and w.pdf
Simplify and write the answer with positive exponents Simplify and w.pdfSimplify and write the answer with positive exponents Simplify and w.pdf
Simplify and write the answer with positive exponents Simplify and w.pdfindiaartz
 
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdf
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdfQuestion 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdf
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdfindiaartz
 
Problem 12-9ACondensed financial data of Waterway Industries follo.pdf
Problem 12-9ACondensed financial data of Waterway Industries follo.pdfProblem 12-9ACondensed financial data of Waterway Industries follo.pdf
Problem 12-9ACondensed financial data of Waterway Industries follo.pdfindiaartz
 
Please help me with these 3 questions! True or False. Assortment of .pdf
Please help me with these 3 questions! True or False. Assortment of .pdfPlease help me with these 3 questions! True or False. Assortment of .pdf
Please help me with these 3 questions! True or False. Assortment of .pdfindiaartz
 
Performance BudgetingPerformance budgeting has been attempted at t.pdf
Performance BudgetingPerformance budgeting has been attempted at t.pdfPerformance BudgetingPerformance budgeting has been attempted at t.pdf
Performance BudgetingPerformance budgeting has been attempted at t.pdfindiaartz
 
Many bridges are made from rebar-reinforced concrete composites. Cla.pdf
Many bridges are made from rebar-reinforced concrete composites. Cla.pdfMany bridges are made from rebar-reinforced concrete composites. Cla.pdf
Many bridges are made from rebar-reinforced concrete composites. Cla.pdfindiaartz
 
If the cystic fibrosis allele protects against tuberculosis the same .pdf
If the cystic fibrosis allele protects against tuberculosis the same .pdfIf the cystic fibrosis allele protects against tuberculosis the same .pdf
If the cystic fibrosis allele protects against tuberculosis the same .pdfindiaartz
 
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdf
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdfMatch the graph of the sine function to the equation over [-4 Pi. 4 P.pdf
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdfindiaartz
 
location in the stem, function, and Chemical Composition of their Wa.pdf
location in the stem, function, and Chemical Composition of their Wa.pdflocation in the stem, function, and Chemical Composition of their Wa.pdf
location in the stem, function, and Chemical Composition of their Wa.pdfindiaartz
 
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdf
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdfIf Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdf
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdfindiaartz
 
Given the global financial crisis of 2007–2009, do you anticipate an.pdf
Given the global financial crisis of 2007–2009, do you anticipate an.pdfGiven the global financial crisis of 2007–2009, do you anticipate an.pdf
Given the global financial crisis of 2007–2009, do you anticipate an.pdfindiaartz
 
Generativity versus stagnation        Early adult transitio.pdf
Generativity versus stagnation        Early adult transitio.pdfGenerativity versus stagnation        Early adult transitio.pdf
Generativity versus stagnation        Early adult transitio.pdfindiaartz
 
Genetics Question 2 In the insect sex determination system, th.pdf
Genetics Question 2 In the insect sex determination system, th.pdfGenetics Question 2 In the insect sex determination system, th.pdf
Genetics Question 2 In the insect sex determination system, th.pdfindiaartz
 
Explain why malaria infection may lead to anemia. How would you clas.pdf
Explain why malaria infection may lead to anemia. How would you clas.pdfExplain why malaria infection may lead to anemia. How would you clas.pdf
Explain why malaria infection may lead to anemia. How would you clas.pdfindiaartz
 
Figure 13.2 of a single pair of homologous chromosomes as they might.pdf
Figure 13.2 of a single pair of homologous chromosomes as they might.pdfFigure 13.2 of a single pair of homologous chromosomes as they might.pdf
Figure 13.2 of a single pair of homologous chromosomes as they might.pdfindiaartz
 
Every individual produced by sexual reproduction is unique. This is .pdf
Every individual produced by sexual reproduction is unique. This is .pdfEvery individual produced by sexual reproduction is unique. This is .pdf
Every individual produced by sexual reproduction is unique. This is .pdfindiaartz
 
Explain to them the probability of future offspring being normal or h.pdf
Explain to them the probability of future offspring being normal or h.pdfExplain to them the probability of future offspring being normal or h.pdf
Explain to them the probability of future offspring being normal or h.pdfindiaartz
 
explain conceptual questionsvariabilitystandard devationz-sc.pdf
explain conceptual questionsvariabilitystandard devationz-sc.pdfexplain conceptual questionsvariabilitystandard devationz-sc.pdf
explain conceptual questionsvariabilitystandard devationz-sc.pdfindiaartz
 
Explain the difference between fermentation and respiration in biolo.pdf
Explain the difference between fermentation and respiration in biolo.pdfExplain the difference between fermentation and respiration in biolo.pdf
Explain the difference between fermentation and respiration in biolo.pdfindiaartz
 

More from indiaartz (20)

Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdf
Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdfSome Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdf
Some Calvin Cycle enzymes contain disulfide bonds that must be reduc.pdf
 
Simplify and write the answer with positive exponents Simplify and w.pdf
Simplify and write the answer with positive exponents Simplify and w.pdfSimplify and write the answer with positive exponents Simplify and w.pdf
Simplify and write the answer with positive exponents Simplify and w.pdf
 
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdf
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdfQuestion 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdf
Question 7 (of 20) 7. 1000 poants TB 1301 which of the following an.pdf
 
Problem 12-9ACondensed financial data of Waterway Industries follo.pdf
Problem 12-9ACondensed financial data of Waterway Industries follo.pdfProblem 12-9ACondensed financial data of Waterway Industries follo.pdf
Problem 12-9ACondensed financial data of Waterway Industries follo.pdf
 
Please help me with these 3 questions! True or False. Assortment of .pdf
Please help me with these 3 questions! True or False. Assortment of .pdfPlease help me with these 3 questions! True or False. Assortment of .pdf
Please help me with these 3 questions! True or False. Assortment of .pdf
 
Performance BudgetingPerformance budgeting has been attempted at t.pdf
Performance BudgetingPerformance budgeting has been attempted at t.pdfPerformance BudgetingPerformance budgeting has been attempted at t.pdf
Performance BudgetingPerformance budgeting has been attempted at t.pdf
 
Many bridges are made from rebar-reinforced concrete composites. Cla.pdf
Many bridges are made from rebar-reinforced concrete composites. Cla.pdfMany bridges are made from rebar-reinforced concrete composites. Cla.pdf
Many bridges are made from rebar-reinforced concrete composites. Cla.pdf
 
If the cystic fibrosis allele protects against tuberculosis the same .pdf
If the cystic fibrosis allele protects against tuberculosis the same .pdfIf the cystic fibrosis allele protects against tuberculosis the same .pdf
If the cystic fibrosis allele protects against tuberculosis the same .pdf
 
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdf
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdfMatch the graph of the sine function to the equation over [-4 Pi. 4 P.pdf
Match the graph of the sine function to the equation over [-4 Pi. 4 P.pdf
 
location in the stem, function, and Chemical Composition of their Wa.pdf
location in the stem, function, and Chemical Composition of their Wa.pdflocation in the stem, function, and Chemical Composition of their Wa.pdf
location in the stem, function, and Chemical Composition of their Wa.pdf
 
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdf
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdfIf Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdf
If Zn Binomial (n, ) , and n~possion(), find the distribution of Z .pdf
 
Given the global financial crisis of 2007–2009, do you anticipate an.pdf
Given the global financial crisis of 2007–2009, do you anticipate an.pdfGiven the global financial crisis of 2007–2009, do you anticipate an.pdf
Given the global financial crisis of 2007–2009, do you anticipate an.pdf
 
Generativity versus stagnation        Early adult transitio.pdf
Generativity versus stagnation        Early adult transitio.pdfGenerativity versus stagnation        Early adult transitio.pdf
Generativity versus stagnation        Early adult transitio.pdf
 
Genetics Question 2 In the insect sex determination system, th.pdf
Genetics Question 2 In the insect sex determination system, th.pdfGenetics Question 2 In the insect sex determination system, th.pdf
Genetics Question 2 In the insect sex determination system, th.pdf
 
Explain why malaria infection may lead to anemia. How would you clas.pdf
Explain why malaria infection may lead to anemia. How would you clas.pdfExplain why malaria infection may lead to anemia. How would you clas.pdf
Explain why malaria infection may lead to anemia. How would you clas.pdf
 
Figure 13.2 of a single pair of homologous chromosomes as they might.pdf
Figure 13.2 of a single pair of homologous chromosomes as they might.pdfFigure 13.2 of a single pair of homologous chromosomes as they might.pdf
Figure 13.2 of a single pair of homologous chromosomes as they might.pdf
 
Every individual produced by sexual reproduction is unique. This is .pdf
Every individual produced by sexual reproduction is unique. This is .pdfEvery individual produced by sexual reproduction is unique. This is .pdf
Every individual produced by sexual reproduction is unique. This is .pdf
 
Explain to them the probability of future offspring being normal or h.pdf
Explain to them the probability of future offspring being normal or h.pdfExplain to them the probability of future offspring being normal or h.pdf
Explain to them the probability of future offspring being normal or h.pdf
 
explain conceptual questionsvariabilitystandard devationz-sc.pdf
explain conceptual questionsvariabilitystandard devationz-sc.pdfexplain conceptual questionsvariabilitystandard devationz-sc.pdf
explain conceptual questionsvariabilitystandard devationz-sc.pdf
 
Explain the difference between fermentation and respiration in biolo.pdf
Explain the difference between fermentation and respiration in biolo.pdfExplain the difference between fermentation and respiration in biolo.pdf
Explain the difference between fermentation and respiration in biolo.pdf
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

This is a C# project . I am expected to create as this image shows. .pdf

  • 1. This is a C# project . I am expected to create as this image shows. If the image isnot clearly showing , it's the Chegg's system. Please , if you see it quit long, assist me with the starting and hinting bulltes point or functions that may simplify. Thannks... The design of the Calculator form Operation · To clear the contents of memory, the user clicks the MC button. To save the value that’s currently displayed in memory, the user clicks the MS button. To recall the value that’s currently in memory and display it in the calculator, the user clicks the MR button. And to add the value that’s currently displayed to the value in memory, the user clicks the M+ button. · An M is displayed in the box above the MC button whenever the memory contains a value. · See project 12-1 for additional details. Specifications · Create a class named MemoryCalculator that inherits the Calculator class described in project 12-1. The MemoryCalculator class should add properties and methods as needed to implement the memory function. Note: · MemoryCalculator class design: Method Description MemoryStore Stores the calculator’s current value in memory. MemoryRecall Sets the calculator’s current value to the value stored in memory. MemoryAdd Adds the calculator’s current value to the value currently stored in memory. MemoryClear Clears the current memory value. Solution Calculator.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Calculator {
  • 2. public class Calculator { public decimal currentValue; private decimal operand1; public decimal operand2; private Operator op; public enum Operator { Addd, Subtract, Multiply, Divide, None }; //Needed to be changed from private to public public Calculator() { this.currentValue = 0; this.operand1 = 0; this.operand2 = 0; this.op = Operator.None; } public decimal CurrentValue { get { return this.currentValue; } } public void Clear() { this.currentValue = 0; this.operand1 = 0; this.operand2 = 0; this.op = Operator.None; } public void Add(decimal val) { this.operand1 = val; this.currentValue = val; this.op = Operator.Addd; } public void Subtract(decimal val) { this.operand1 = val; this.currentValue = val;
  • 3. this.op = Operator.Subtract; } public void Multiply(decimal val) { this.operand1 = val; this.currentValue = val; this.op = Operator.Multiply; } public void Divide(decimal val) { this.operand1 = val; this.currentValue = val; this.op = Operator.Divide; } public void Equals(decimal val) { operand2 = val; switch (this.op) { case Operator.Addd: currentValue = operand1 + operand2; break; case Operator.Subtract: currentValue = operand1 - operand2; break; case Operator.Multiply: currentValue = operand1 * operand2; break; case Operator.Divide: //Try catch to prevent dividing by zero try { currentValue = operand1 / operand2; } catch (DivideByZeroException)
  • 4. { MessageBox.Show("You cannot divide by zero", "Error!"); } break; case Operator.None: currentValue = operand2; break; } operand1 = currentValue; } public void SquareRoot(decimal val) { this.operand1 = val; currentValue = (decimal)Math.Sqrt(Convert.ToDouble(operand1)); op = Operator.None; } public void Reciprocal(decimal val) { this.operand1 = val; currentValue = 1 / operand1; op = Operator.None; } } } MemoryCalculator.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Calculator { public class MemoryCalculator : Calculator { //variable to hold the memory
  • 5. private static decimal memoryStorage; private static string dispValue; public MemoryCalculator(decimal memory) { this.MemoryStorage = memory; } //added string constructor to get the display value from form1 //this will allow me to add what ever is inputed to be added to memoryStorage (MemoryAdd function) public MemoryCalculator(string displayValue) { this.DisplayValue = displayValue; } public string DisplayValue { get { return dispValue; } set { dispValue = value; } } public decimal MemoryStorage { get { return memoryStorage; } set { memoryStorage = value; } } public decimal memoryStore()
  • 6. { //save memoryStorage memoryStorage = this.MemoryStorage; //going to return this to put in the txtMemory text box return memoryStorage; } public decimal memoryAdd() { //declare array to define what numbers to add decimal[] addens = { Convert.ToDecimal(this.DisplayValue), memoryStorage }; //add memoryStorage and current value memoryStorage = addens.Sum(); return memoryStorage; } public void memoryClear() { //set memoryStorage to 0 memoryStorage = 0; } public decimal memoryRecall() { // return memoryStorage return memoryStorage; } } } Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
  • 7. using System.Threading.Tasks; using System.Windows.Forms; namespace Calculator { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private string displayString; //Needs to be decimal private decimal displayValue; private bool newValue; private bool decimalEntered; private Calculator Calc = new Calculator(); //define MemoryCalculator class private MemoryCalculator calcMem = new MemoryCalculator(0); private void Form1_Load(object sender, System.EventArgs e) { //Initializes values displayValue = 0; displayString = ""; newValue = true; decimalEntered = false; } private void btnNumber_Click(object sender, System.EventArgs e) { if (newValue) { displayString = ""; newValue = false;
  • 8. } //Sends button value to textbox displayString += ((Button)sender).Tag.ToString(); displayValue = Convert.ToDecimal(displayString); txtDisplay.Text = displayString; } private void btnBackSpace_Click(object sender, System.EventArgs e) { if (!newValue) { if (displayString.Length > 1) { displayString = displayString.Substring(0, displayString.Length - 1); displayValue = Convert.ToDecimal(displayString); txtDisplay.Text = displayString; } else if (displayString.Length == 1) { displayValue = Calc.CurrentValue; displayString = displayValue.ToString(); txtDisplay.Text = displayString; newValue = true; } } } private void btnClear_Click(object sender, System.EventArgs e) { Calc.Clear(); displayString = ""; displayValue = 0; txtDisplay.Text = displayValue.ToString(); newValue = true; decimalEntered = false; }
  • 9. private void btnDecimal_Click(object sender, System.EventArgs e) { if (!decimalEntered) { displayString += "."; //un-needed line of code? //displayValue = Convert.ToInt16(displayString); txtDisplay.Text = displayString; decimalEntered = true; } else { MessageBox.Show("You can only input 1 decimal!", "Error!"); } } private void btnSign_Click(object sender, System.EventArgs e) { displayValue = -displayValue; txtDisplay.Text = displayValue.ToString(); } private void btnAdd_Click(object sender, System.EventArgs e) { Calc.Add(displayValue); newValue = true; decimalEntered = false; displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); } private void btnSubtract_Click(object sender, System.EventArgs e) { Calc.Subtract(displayValue); newValue = true; decimalEntered = false; displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); }
  • 10. private void btnMultiply_Click(object sender, System.EventArgs e) { Calc.Multiply(displayValue); newValue = true; decimalEntered = false; displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); } private void btnDivide_Click(object sender, System.EventArgs e) { Calc.Divide(displayValue); newValue = true; decimalEntered = false; displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); } private void btnSqrt_Click(object sender, System.EventArgs e) { Calc.SquareRoot(displayValue); displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); } private void btnReciprocal_Click(object sender, System.EventArgs e) { try { Calc.Reciprocal(displayValue); displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); } catch (DivideByZeroException) { displayValue = 0; txtDisplay.Text = "Cannot divide by zero."; newValue = true; decimalEntered = false;
  • 11. } } private void btnEquals_Click(object sender, System.EventArgs e) { if (newValue) Calc.Equals(displayValue); else Calc.Equals(displayValue); displayValue = Calc.CurrentValue; txtDisplay.Text = displayValue.ToString(); newValue = true; decimalEntered = false; } private void btnMS_Click(object sender, EventArgs e) { //pass displayValue to the MemoryCalculator class calcMem = new MemoryCalculator(displayValue); calcMem.memoryStore(); txtMemory.Text = 'M'.ToString(); } private void btnMAdd_Click(object sender, EventArgs e) { calcMem = new MemoryCalculator(displayValue.ToString()); calcMem.memoryAdd(); txtMemory.Text = 'M'.ToString(); } private void btnMC_Click(object sender, EventArgs e) { calcMem.memoryClear(); txtMemory.Text = ' '.ToString(); } private void btnMR_Click(object sender, EventArgs e) { //store recalled memory into a variable to be used to display text, and set displayValue text
  • 12. decimal recalledMemory = calcMem.memoryRecall(); displayValue = recalledMemory; txtDisplay.Text = (recalledMemory.ToString()); //reset memory after it is recalled calcMem.memoryClear(); txtMemory.Text = ' '.ToString(); } } } Program.cs using System; using System.Collections.Generic; using System.Threading.Tasks; using System.Windows.Forms; namespace Calculator { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } Note: i cant able to upload Form1.Designer.cs file due to more character. we have limited to post 65,000 characters only