If the user enters the memory key (“m”), your calculator should display the last value or operator stored in memory.


private: System::Void One_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "1";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "1";
}

endProcess = false;
}

private: System::Void Two_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "2";

}
else
{
Display->Text = Convert::ToString(Display->Text) + "2";

}

endProcess = false;
}

private: System::Void Three_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "3";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "3";
}

endProcess = false;
}

private: System::Void Four_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "4";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "4";
}

endProcess = false;
}

private: System::Void Five_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "5";

}
else
{
Display->Text = Convert::ToString(Display->Text) + "5";
}

endProcess = false;
}

private: System::Void Six_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "6";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "6";
}

endProcess = false;
}

private: System::Void Seven_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "7";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "7";

}

endProcess = false;
}

private: System::Void Eight_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "8";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "8";
}

endProcess = false;
}

private: System::Void Nine_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "9";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "9";
}

endProcess = false;
}

private: System::Void Zero_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "0";
}
else
{
Display->Text = Convert::ToString(Display->Text) + "0";
}

endProcess = false;
}

private: System::Void Subtraction_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text=="0")
{
Display->Text = "-";
}
else
{
Display->Text = Convert::ToString(Display->Text) + " - ";
}

endProcess = false;
}

private: System::Void Addition_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text=="0")
{
//Display->Text = " + ";
}
else
{
Display->Text = Convert::ToString(Display->Text) + " + ";
}

endProcess = false;
}

private: System::Void Division_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text == "0")
{
//Display->Text = " / ";
}
else
{
Display->Text = Convert::ToString(Display->Text) + " / ";
}

endProcess = false;

}

private: System::Void Multiplication_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text=="0")
{
//Display->Text = "*";
}
else
{
Display->Text = Convert::ToString(Display->Text) + " * ";
}

endProcess = false;
}

private: System::Void Backspace_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text->Length >0)
{
//deletes the last character displayed on screen
Display->Text = Display->Text->Substring(0,Display->Text->Length - 1);
}

endProcess = false;
}

private: System::Void Decimal_Click(System::Object^ sender, System::EventArgs^ e) {

if(endProcess)
Display->Text = "0";

if(Display->Text=="0")
{
Display->Text = "0.";
}
else
{
Display->Text = Convert::ToString(Display->Text) + ".";
}

endProcess = false;

}//end of decimal point function

private: System::Void Space_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text=="0")
{
Display->Text = " ";
}
else
{
Display->Text = Convert::ToString(Display->Text) + " ";
}

//allows new number to be appended to end of display text
endProcess = false;
}

private: System::Void Clear_Click(System::Object^ sender, System::EventArgs^ e) {

//clears the calculator screen
Display->Text = "0";

}

private: System::Void Power_Click(System::Object^ sender, System::EventArgs^ e) {

if(Display->Text=="0"){

// Display->Text = "^";
}
else{
Display->Text = Convert::ToString(Display->Text) + " ^ ";
}

endProcess = false;
}

private: System::Void Exit_Click(System::Object^ sender, System::EventArgs^ e) {

//assigns error message to system string variable 'message'
String^ message = "Are you sure?";

//display dialog box with error message
MessageBox::Show(message);

//exit system
exit(1);

}//end exit button

private: System::Void ClearFile_Click(System::Object^ sender, System::EventArgs^ e) {

//declaration of file pointer
ofstream expression;

//create a new file in text mode
expression.open("expression.txt", ios::out );

//check if file is open
if(expression.is_open())
{
// expression << input << endl;
expression.close();
}
else {

//assigns error message to system string variable 'message'
String^ message = "Unable to open file";

//display dialog box with error message
MessageBox::Show(message);

}//end if
}

private: System::Void FileButton_Click(System::Object^ sender, System::EventArgs^ e) {//File button function

//declaration of file pointer
ofstream expression;

//open file to appened display text to end of file
expression.open("expression.txt", ios::app);

//converts display text from system string to standard string
std::string input = msclr::interop::marshal_as< std::string >(Display->Text);

//check if file is open
if(expression.is_open())
{
//Write to file
expression << input << endl;

//close file
expression.close();
}
else
{
//assigns error message to system string variable 'message'
String^ message = "Unable to open file";

//display dialog box with error message
MessageBox::Show(message);

} // end if
}

private: System::Void MemoryRecall_Click(System::Object^ sender, System::EventArgs^ e) {


}

private: System::Void Equal_Click(System::Object^ sender, System::EventArgs^ e) {

endProcess = false;

if (Display->Text == "0"){
//empty function
}
else{
std::string infixExpression = msclr::interop::marshal_as< std::string >(Display->Text);

//invoke the method convertedinfix to convert from infix to postfix
string postfixExpression = ConvertInfix(infixExpression);

//manipulatea the expression for calculation
manipulatePostfix( postfixExpression );

//prevents numbers from being appended to end of display text
endProcess = true;
}

}//end equal button
//Class within a class to handle convertion and calculations



yeh. Im not gonna read through this program. So be more specific. Whats wrong here? What line of code?

Also please edit your post and put the code between code tags - http://www.cplusplus.com/articles/jEywvCM9/
i'm creating a calculator using visual studios, the language being used is C++
one of the requirement is to have a button that when pressed it returns the last key or operator that the user entered.

how can i implement that key within the code?

private: System::Void MemoryRecall_Click(System::Object^ sender, System::EventArgs^ e) {


}

i've used stacks through out the program
language being used is C++
It is not C++.

It is C++/CLI: another language created by Microsoft.
thanks for the correction MiiNiPaa, anything to comment about the code itself?
You can start by doing what I told you to do.
Topic archived. No new replies allowed.