#include
#include
using namespace System;
using namespace System::Windows::Forms;
public ref class CalculatorForm : public Form
{
private:
TextBox^ txtInput;
Button^ btnAdd;
Button^ btnSubtract;
Button^ btnMultiply;
Button^ btnDivide;
Button^ btnEquals;
double total1;
double total2;
public:
CalculatorForm()
{
txtInput = gcnew TextBox();
txtInput->Location = Point(10, 10);
txtInput->Width = 200;
Controls->Add(txtInput);
btnAdd = gcnew Button();
btnAdd->Text = L"+";
btnAdd->Location = Point(10, 40);
btnAdd->Click += gcnew EventHandler(this, &CalculatorForm::btnAdd_Click);
Controls->Add(btnAdd);
// Добавьте остальные кнопки и обработчики событий аналогично
btnEquals = gcnew Button();
btnEquals->Text = L"=";
btnEquals->Location = Point(10, 160);
btnEquals->Click += gcnew EventHandler(this, &CalculatorForm::btnEquals_Click);
Controls->Add(btnEquals);
}
void btnAdd_Click(Object^ sender, EventArgs^ e)
{
total1 += Double::Parse(txtInput->Text);
txtInput->Clear();
}
// Реализуйте остальные обработчики событий для вычитания, умножения и деления
void btnEquals_Click(Object^ sender, EventArgs^ e)
{
total2 = total1;
txtInput->Text = total2.ToString();
total1 = 0;
}
};
[STAThread]
void Main(array^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew CalculatorForm());
}