Calculation.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsСигаева2ИС_ПР2
  11. {
  12. /// <summary>
  13. /// Класс Calculation для вычисления выражения
  14. /// </summary>
  15. public partial class Calculation : Form
  16. {
  17. /// <summary>
  18. /// Конструктор
  19. /// </summary>
  20. public Calculation()
  21. {
  22. InitializeComponent();
  23. }
  24. /// <summary>
  25. /// Кнопка для вычисления выражения
  26. /// </summary>
  27. /// <param name="sender"></param>
  28. /// <param name="e"></param>
  29. private void ButtonCalculation_Click(object sender, EventArgs e)
  30. {
  31. if
  32. (double.TryParse(textBoxA.Text, out double a) &&
  33. double.TryParse(textBoxX.Text, out double x) &&
  34. double.TryParse(textBoxC.Text, out double c) &&
  35. double.TryParse(textBoxD.Text, out double d))
  36. {
  37. double f = Math.Sqrt((c - d) * (Math.Pow(x, 2))) / x;
  38. double q = Math.Log((Math.Pow(x, 2)) + c) / ((0.7 * x) + (a*d));
  39. double n = (Math.Pow(10, -2)) / (c - (d * Math.Pow(x, 3)));
  40. double result = f + q + n;
  41. textBoxResult.Text += Environment.NewLine + result.ToString();
  42. }
  43. }
  44. }
  45. }