Главная страница

Лабораторная работа 13 vol 2. Построение и обоснование модели проекта


Скачать 0.61 Mb.
НазваниеПостроение и обоснование модели проекта
Дата29.04.2022
Размер0.61 Mb.
Формат файлаdocx
Имя файлаЛабораторная работа 13 vol 2.docx
ТипЛабораторная работа
#504361
страница3 из 3
1   2   3

this->Controls->Add(this->button11);

this->Controls->Add(this->button10);

this->Controls->Add(this->button9);

this->Controls->Add(this->button8);

this->Controls->Add(this->button7);

this->Controls->Add(this->button6);

this->Controls->Add(this->label2);

this->Controls->Add(this->button5);

this->Controls->Add(this->button4);

this->Controls->Add(this->button3);

this->Controls->Add(this->button2);

this->Controls->Add(this->button1);

this->Controls->Add(this->label1);

this->Controls->Add(this->textBox2);

this->Controls->Add(this->textBox1);

this->Name = L"MyForm";

this->Text = L"Калькулятор";

this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);

this->ResumeLayout(false);

this->PerformLayout();
}

Single firstNum; //Хранится первое число

Single secondNum; //Хранится второе число

Single result; //Хранится результат действий

Single result2;

bool vvod;

bool isNumber = true; //Проверка на число

#pragma endregion

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

{

this->Text = "Калькулятор vol. 2";

button1->Text = "+";

button2->Text = "-";

button3->Text = "*";

button4->Text = "/";

button5->Text = "cos()";

button6->Text = "sin()";

button7->Text = "Кв. корень";

button8->Text = "x^y";

button9->Text = "1";

button10->Text = "2";

button11->Text = "3";

button12->Text = "4";

button13->Text = "5";

button14->Text = "6";

button15->Text = "7";

button16->Text = "8";

button17->Text = "9";

button18->Text = "0";

button19->Text = "ВВОД";

button20->Text = "<-";

label1->Text = String::Empty;

textBox1->Clear();

textBox1->ReadOnly = true;

textBox2->Clear();

textBox2->ReadOnly = true;

textBox1->TabIndex = 0;

vvod = true;

label2->Text = "Значения для функций cos() и sin() необходимо вводить в градусах.\nКлавиша ВВод переключает между числами.";

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = firstNum + secondNum;

label1->Text = String::Format("{0}+{1}={2}", firstNum, secondNum, result);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = firstNum - secondNum;

label1->Text = String::Format("{0}-{1}={2}", firstNum, secondNum, result);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = firstNum * secondNum;

label1->Text = String::Format("{0}*{1}={2}", firstNum, secondNum, result);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = firstNum / secondNum;

label1->Text = String::Format("{0}/{1}={2}", firstNum, secondNum, result);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = cos((firstNum*M_PI/180));

result2 = cos((secondNum*M_PI/180));

label1->Text = String::Format("cos({0})={1} cos({2})={3}", firstNum, result, secondNum, result2);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = sin((firstNum * M_PI / 180));

result2 = sin((secondNum * M_PI / 180));

label1->Text = String::Format("sin({0})={1} sin({2})={3}", firstNum, result, secondNum, result2);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = sqrt(firstNum);

result2 = sqrt(secondNum);
label1->Text = String::Format("Кв.корень({0})={1} Кв.корень({2})={3}", firstNum, result, secondNum, result2);

}

}

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

{

label1->ForeColor = Color::Black;

isNumber = (Single::TryParse(

textBox1->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

firstNum)

&& (Single::TryParse(

textBox2->Text,

System::Globalization::NumberStyles::Number,

System::Globalization::NumberFormatInfo::CurrentInfo,

secondNum)));

if (isNumber == false)

{

label1->Text = "Введены некорректные данные"; //Выводим сообщение на экран

label1->ForeColor = Color::Red;

return;

}

else

{

result = pow(firstNum, secondNum);
label1->Text = String::Format("{0}^{1}={2}", firstNum, secondNum, result);

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button9->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button9->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button10->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button10->Text;

}

}

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

{

if (vvod == true)

{

vvod = false;

}

else

{

vvod = true;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button11->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button11->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button12->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button12->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button13->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button13->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button14->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button14->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button15->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button15->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button16->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button16->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button17->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button17->Text;

}

}

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

{

if (vvod == true)

{

textBox1->Text = textBox1->Text + button18->Text;

}

if (vvod == false)

{

textBox2->Text = textBox2->Text + button18->Text;

}

}

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

{

if (vvod == true)

{

if (textBox1->Text->Length != 0)

{

textBox1->Text = textBox1->Text->Remove(textBox1->Text->Length - 1);

}

else

{

textBox1->Text = textBox1->Text->Insert(textBox1->Text->Length, "");

}

}

if (vvod == false)

{

if (textBox2->Text->Length != 0)

{

textBox2->Text = textBox2->Text->Remove(textBox2->Text->Length - 1);

}

else

{

textBox2->Text = textBox2->Text->Insert(textBox2->Text->Length, "");

}

}

}

};

}
1   2   3


написать администратору сайта