Advertisement
Vova12341231

123123123

Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.12 KB | None | 0 0
  1. //завдання 1
  2. #pragma once
  3. #include <math.h>
  4.  
  5. namespace rozr2n {
  6.  
  7. using namespace System;
  8. using namespace System::ComponentModel;
  9. using namespace System::Collections;
  10. using namespace System::Windows::Forms;
  11. using namespace System::Data;
  12. using namespace System::Drawing;
  13.  
  14. public ref class main : public System::Windows::Forms::Form
  15. {
  16. public:
  17. main(void)
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. protected:
  23. ~main()
  24. {
  25. if (components)
  26. {
  27. delete components;
  28. }
  29. }
  30. private: System::Windows::Forms::Label^ label1;
  31. private: System::Windows::Forms::Label^ label2;
  32. private: System::Windows::Forms::Label^ label3;
  33. private: System::Windows::Forms::TextBox^ textBox1;
  34. private: System::Windows::Forms::TextBox^ textBox2;
  35. private: System::Windows::Forms::TextBox^ textBox3;
  36. private: System::Windows::Forms::Button^ button1;
  37. private: System::Windows::Forms::Label^ label4;
  38.  
  39. protected:
  40.  
  41. private:
  42. System::ComponentModel::Container ^components;
  43.  
  44. #pragma region Windows Form Designer generated code
  45. void InitializeComponent(void)
  46. {
  47. this->label1 = (gcnew System::Windows::Forms::Label());
  48. this->label2 = (gcnew System::Windows::Forms::Label());
  49. this->label3 = (gcnew System::Windows::Forms::Label());
  50. this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  51. this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  52. this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  53. this->button1 = (gcnew System::Windows::Forms::Button());
  54. this->label4 = (gcnew System::Windows::Forms::Label());
  55. this->SuspendLayout();
  56. //
  57. // label1
  58. //
  59. this->label1->AutoSize = true;
  60. this->label1->Location = System::Drawing::Point(12, 12);
  61. this->label1->Name = L"label1";
  62. this->label1->Size = System::Drawing::Size(32, 13);
  63. this->label1->TabIndex = 0;
  64. this->label1->Text = L"Сила";
  65. //
  66. // label2
  67. //
  68. this->label2->AutoSize = true;
  69. this->label2->Location = System::Drawing::Point(12, 36);
  70. this->label2->Name = L"label2";
  71. this->label2->Size = System::Drawing::Size(66, 13);
  72. this->label2->TabIndex = 1;
  73. this->label2->Text = L"Жорсткість";
  74. //
  75. // label3
  76. //
  77. this->label3->AutoSize = true;
  78. this->label3->Location = System::Drawing::Point(12, 60);
  79. this->label3->Name = L"label3";
  80. this->label3->Size = System::Drawing::Size(54, 13);
  81. this->label3->TabIndex = 2;
  82. this->label3->Text = L"Довжина";
  83. //
  84. // textBox1
  85. //
  86. this->textBox1->Location = System::Drawing::Point(100, 9);
  87. this->textBox1->Name = L"textBox1";
  88. this->textBox1->ReadOnly = true;
  89. this->textBox1->Size = System::Drawing::Size(159, 20);
  90. this->textBox1->TabIndex = 3;
  91. //
  92. // textBox2
  93. //
  94. this->textBox2->Location = System::Drawing::Point(100, 33);
  95. this->textBox2->Name = L"textBox2";
  96. this->textBox2->Size = System::Drawing::Size(159, 20);
  97. this->textBox2->TabIndex = 4;
  98. //
  99. // textBox3
  100. //
  101. this->textBox3->Location = System::Drawing::Point(100, 57);
  102. this->textBox3->Name = L"textBox3";
  103. this->textBox3->Size = System::Drawing::Size(159, 20);
  104. this->textBox3->TabIndex = 5;
  105. //
  106. // button1
  107. //
  108. this->button1->Location = System::Drawing::Point(12, 85);
  109. this->button1->Name = L"button1";
  110. this->button1->Size = System::Drawing::Size(76, 23);
  111. this->button1->TabIndex = 6;
  112. this->button1->Text = L"Обчислити";
  113. this->button1->UseVisualStyleBackColor = true;
  114. this->button1->Click += gcnew System::EventHandler(this, &main::button1_Click);
  115. //
  116. // label4
  117. //
  118. this->label4->AutoSize = true;
  119. this->label4->Location = System::Drawing::Point(97, 90);
  120. this->label4->Name = L"label4";
  121. this->label4->Size = System::Drawing::Size(0, 13);
  122. this->label4->TabIndex = 7;
  123. //
  124. // main
  125. //
  126. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  127. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  128. this->ClientSize = System::Drawing::Size(287, 117);
  129. this->Controls->Add(this->label4);
  130. this->Controls->Add(this->button1);
  131. this->Controls->Add(this->textBox3);
  132. this->Controls->Add(this->textBox2);
  133. this->Controls->Add(this->textBox1);
  134. this->Controls->Add(this->label3);
  135. this->Controls->Add(this->label2);
  136. this->Controls->Add(this->label1);
  137. this->Name = L"main";
  138. this->Text = L"Обчислення сили пружності";
  139. this->ResumeLayout(false);
  140. this->PerformLayout();
  141.  
  142. }
  143. #pragma endregion
  144. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  145. label4->Text = "";
  146. if (textBox2->Text != "" && textBox3->Text != "") {
  147. double k = Convert::ToDouble(textBox2->Text);
  148. double x = Convert::ToDouble(textBox3->Text);
  149. textBox1->Text = double(k * x * x) + "";
  150. } else {
  151. label4->Text = "Введених даних недостатньо";
  152. return;
  153. }
  154. }
  155. };
  156. }
  157.  
  158.  
  159.  
  160.  
  161.  
  162. //завдання 2
  163. #pragma once
  164. #include <math.h>
  165.  
  166. namespace rozr2n {
  167.  
  168. using namespace System;
  169. using namespace System::ComponentModel;
  170. using namespace System::Collections;
  171. using namespace System::Windows::Forms;
  172. using namespace System::Data;
  173. using namespace System::Drawing;
  174.  
  175. public ref class main : public System::Windows::Forms::Form
  176. {
  177. public:
  178. main(void)
  179. {
  180. InitializeComponent();
  181. }
  182.  
  183. protected:
  184. ~main()
  185. {
  186. if (components)
  187. {
  188. delete components;
  189. }
  190. }
  191. private: System::Windows::Forms::Label^ label1;
  192. private: System::Windows::Forms::Label^ label2;
  193. private: System::Windows::Forms::Label^ label3;
  194. private: System::Windows::Forms::TextBox^ textBox1;
  195. private: System::Windows::Forms::TextBox^ textBox2;
  196. private: System::Windows::Forms::TextBox^ textBox3;
  197. private: System::Windows::Forms::Button^ button1;
  198. private: System::Windows::Forms::Label^ label4;
  199. private: System::Windows::Forms::Button^ button2;
  200.  
  201. protected:
  202.  
  203. private:
  204. System::ComponentModel::Container ^components;
  205.  
  206. #pragma region Windows Form Designer generated code
  207. void InitializeComponent(void)
  208. {
  209. this->label1 = (gcnew System::Windows::Forms::Label());
  210. this->label2 = (gcnew System::Windows::Forms::Label());
  211. this->label3 = (gcnew System::Windows::Forms::Label());
  212. this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  213. this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  214. this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  215. this->button1 = (gcnew System::Windows::Forms::Button());
  216. this->label4 = (gcnew System::Windows::Forms::Label());
  217. this->button2 = (gcnew System::Windows::Forms::Button());
  218. this->SuspendLayout();
  219. //
  220. // label1
  221. //
  222. this->label1->AutoSize = true;
  223. this->label1->Location = System::Drawing::Point(12, 12);
  224. this->label1->Name = L"label1";
  225. this->label1->Size = System::Drawing::Size(32, 13);
  226. this->label1->TabIndex = 0;
  227. this->label1->Text = L"Сила";
  228. //
  229. // label2
  230. //
  231. this->label2->AutoSize = true;
  232. this->label2->Location = System::Drawing::Point(12, 36);
  233. this->label2->Name = L"label2";
  234. this->label2->Size = System::Drawing::Size(66, 13);
  235. this->label2->TabIndex = 1;
  236. this->label2->Text = L"Жорсткість";
  237. //
  238. // label3
  239. //
  240. this->label3->AutoSize = true;
  241. this->label3->Location = System::Drawing::Point(12, 60);
  242. this->label3->Name = L"label3";
  243. this->label3->Size = System::Drawing::Size(54, 13);
  244. this->label3->TabIndex = 2;
  245. this->label3->Text = L"Довжина";
  246. //
  247. // textBox1
  248. //
  249. this->textBox1->Location = System::Drawing::Point(100, 9);
  250. this->textBox1->Name = L"textBox1";
  251. this->textBox1->Size = System::Drawing::Size(159, 20);
  252. this->textBox1->TabIndex = 3;
  253. //
  254. // textBox2
  255. //
  256. this->textBox2->Location = System::Drawing::Point(100, 33);
  257. this->textBox2->Name = L"textBox2";
  258. this->textBox2->Size = System::Drawing::Size(159, 20);
  259. this->textBox2->TabIndex = 4;
  260. //
  261. // textBox3
  262. //
  263. this->textBox3->Location = System::Drawing::Point(100, 57);
  264. this->textBox3->Name = L"textBox3";
  265. this->textBox3->Size = System::Drawing::Size(159, 20);
  266. this->textBox3->TabIndex = 5;
  267. //
  268. // button1
  269. //
  270. this->button1->Location = System::Drawing::Point(12, 85);
  271. this->button1->Name = L"button1";
  272. this->button1->Size = System::Drawing::Size(76, 23);
  273. this->button1->TabIndex = 6;
  274. this->button1->Text = L"Обчислити";
  275. this->button1->UseVisualStyleBackColor = true;
  276. this->button1->Click += gcnew System::EventHandler(this, &main::button1_Click);
  277. //
  278. // label4
  279. //
  280. this->label4->AutoSize = true;
  281. this->label4->Location = System::Drawing::Point(97, 90);
  282. this->label4->Name = L"label4";
  283. this->label4->Size = System::Drawing::Size(0, 13);
  284. this->label4->TabIndex = 7;
  285. //
  286. // button2
  287. //
  288. this->button2->Location = System::Drawing::Point(12, 114);
  289. this->button2->Name = L"button2";
  290. this->button2->Size = System::Drawing::Size(247, 23);
  291. this->button2->TabIndex = 8;
  292. this->button2->Text = L"Очистити";
  293. this->button2->UseVisualStyleBackColor = true;
  294. this->button2->Click += gcnew System::EventHandler(this, &main::button2_Click);
  295. //
  296. // main
  297. //
  298. this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  299. this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  300. this->ClientSize = System::Drawing::Size(287, 144);
  301. this->Controls->Add(this->button2);
  302. this->Controls->Add(this->label4);
  303. this->Controls->Add(this->button1);
  304. this->Controls->Add(this->textBox3);
  305. this->Controls->Add(this->textBox2);
  306. this->Controls->Add(this->textBox1);
  307. this->Controls->Add(this->label3);
  308. this->Controls->Add(this->label2);
  309. this->Controls->Add(this->label1);
  310. this->Name = L"main";
  311. this->Text = L"Обчислення сили пружності";
  312. this->ResumeLayout(false);
  313. this->PerformLayout();
  314.  
  315. }
  316. #pragma endregion
  317. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  318. label4->Text = "";
  319. if (textBox1->Text != "" && textBox2->Text != "") {
  320. double F = Convert::ToDouble(textBox1->Text);
  321. double k = Convert::ToDouble(textBox2->Text);
  322. textBox3->ReadOnly = true;
  323. textBox3->Text = sqrt(F / k) + "";
  324. }
  325. else if (textBox2->Text != "" && textBox3->Text != "") {
  326. double k = Convert::ToDouble(textBox2->Text);
  327. double x = Convert::ToDouble(textBox3->Text);
  328. textBox1->ReadOnly = true;
  329. textBox1->Text = double(k * x * x) + "";
  330. }
  331. else if (textBox3->Text != "" && textBox1->Text != "") {
  332. double F = Convert::ToDouble(textBox1->Text);
  333. double x = Convert::ToDouble(textBox3->Text);
  334. textBox2->ReadOnly = true;
  335. textBox2->Text = double(F / (x*x)) + "";
  336. }
  337. else {
  338. label4->Text = "Введених даних недостатньо";
  339. return;
  340. }
  341. }
  342. private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
  343. label4->Text = "";
  344. textBox1->Text = "";
  345. textBox1->ReadOnly = false;
  346. textBox2->Text = "";
  347. textBox2->ReadOnly = false;
  348. textBox3->Text = "";
  349. textBox3->ReadOnly = false;
  350. }
  351. };
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement