2-LABARATORIYA
Ikkinchi bosqichda quydagi oyna ko`rinishini hosil qilamiz (2-rasm). Bu yerda 6 ta label, 2 ta button,2ta TextBox, 2 ta panel va 1 PictureBox kompanentalarida foydalanilgan. Label1ni panel1ga joylashtirib text xossasiga “2-labaratoriya” deb yozdim. Label2ni panel2ga joylashtirib text xossasiga “Salomov Shoxruhning” deb yozdim.Label3ni text xossasiga “A=” deb yozib, TextBox1 ni yoniga joylashtirdim. Label4ni text xossasiga “B=” deb yozib, TextBox2 ni yoniga joylashtirdim. Button1 va Button2 kompanentasining text xossasiga “C=” va “P=” deb yozib,label5 va label6 ni yaqiniga joylashtirdim. Buni ishlatishda Button1 (C=) bossak gipotenuzani hisoblaydi. Button2 (P=)ni bosilsa perimetrni hisoblaydi. PictureBox1 ga tug`ri burchakli uchburchak rasmini quydim.
2-rasm
Dastur ko`rinishi:
#pragma endregion
private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e)
{
double a, b;
a = Convert::ToDouble(this->textBox1->Text);
b = Convert::ToDouble(this->textBox2->Text);
this->label5->Text = Convert::ToString(sqrt(a*a + b*b));
}
private: System::Void Button2_Click(System::Object^ sender, System::EventArgs^ e)
{
double a, b, c;
a = Convert::ToDouble(this->textBox1->Text);
b = Convert::ToDouble(this->textBox2->Text);
c = sqrt(a * a + b * b);
this->label6->Text = Convert::ToString(a+b+c);}
|
3-LABARATORIYA
private: System::Void Button1_Click_1(System::Object^ sender, System::EventArgs^ e)
{
double n;
n = Convert::ToDouble(textBox1->Text);
if (radioButton1->Checked)
{
label4->Text = "R= " + Convert::ToString(n);
label5->Text = "D= " + Convert::ToString(2*n);
label6->Text = "L= " + Convert::ToString(n*2*Math::PI);
label7->Text = "S= " + Convert::ToString(n*n*Math::PI);
}
if (radioButton2->Checked)
{
label4->Text = "R= " + Convert::ToString(n*1./2);
label5->Text = "D= " + Convert::ToString(n);
label6->Text = "L= " + Convert::ToString(n * Math::PI);
label7->Text = "S= " + Convert::ToString((n * n * Math::PI)*1./4);
}if (radioButton3->Checked)
{
label4->Text = "R= " + Convert::ToString(n*1./(2*Math::PI));
label5->Text = "D= " + Convert::ToString(n*1./Math::PI);
label6->Text = "L= " + Convert::ToString(n);
label7->Text = "S= " + Convert::ToString(n * n *1./(4* Math::PI));
}if (radioButton4->Checked)
{
label4->Text = "R= " + Convert::ToString(Math::Sqrt(n/Math::PI));
label5->Text = "D= " + Convert::ToString(Math::Sqrt(n*4 / Math::PI));
label6->Text = "L= " + Convert::ToString(Math::Sqrt(n*4 / Math::PI));
label7->Text = "S= " + Convert::ToString(Math::Sqrt(n));
}
}
|
Do'stlaringiz bilan baham: |