Form1.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 dyakonovcalc
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20. if (textBox1.Text == "" || textBox2.Text == "")
  21. {
  22. label1.Text = "Введите значения";
  23. }
  24. else
  25. {
  26. double a = Convert.ToInt32(textBox1.Text);
  27. double b = Convert.ToInt32(textBox2.Text);
  28. textBox3.Text = Convert.ToString(a + b);
  29. }
  30. }
  31. private void button2_Click(object sender, EventArgs e)
  32. {
  33. if (textBox1.Text == "" || textBox2.Text == "")
  34. {
  35. label1.Text = "Введите значения";
  36. }
  37. else
  38. {
  39. double a = Convert.ToInt32(textBox1.Text);
  40. double b = Convert.ToInt32(textBox2.Text);
  41. textBox3.Text = Convert.ToString(a - b);
  42. }
  43. }
  44. private void button3_Click(object sender, EventArgs e)
  45. {
  46. if (textBox1.Text == "" || textBox2.Text == "")
  47. {
  48. label1.Text = "Введите значения";
  49. }
  50. else
  51. {
  52. double a = Convert.ToInt32(textBox1.Text);
  53. double b = Convert.ToInt32(textBox2.Text);
  54. textBox3.Text = Convert.ToString(a * b);
  55. }
  56. }
  57. private void button4_Click(object sender, EventArgs e)
  58. {
  59. if (textBox2.Text == "0" || textBox2.Text == "")
  60. {
  61. label1.Text = "На ноль делить нельзя";
  62. }
  63. else
  64. {
  65. double a = Convert.ToInt32(textBox1.Text);
  66. double b = Convert.ToInt32(textBox2.Text);
  67. textBox3.Text = Convert.ToString(a / b);
  68. }
  69. }
  70. private void button5_Click(object sender, EventArgs e)
  71. {
  72. if (textBox1.Text == "" || textBox2.Text == "")
  73. {
  74. label1.Text = "Введите значения";
  75. }
  76. else
  77. {
  78. double a = Convert.ToInt32(textBox1.Text);
  79. double b = Convert.ToInt32(textBox2.Text);
  80. textBox3.Text = Convert.ToString(Math.Pow(a,b));
  81. }
  82. }
  83. private void button6_Click(object sender, EventArgs e)
  84. {
  85. if (textBox1.Text == "" || textBox2.Text == "")
  86. {
  87. label1.Text = "Введите значения";
  88. }
  89. else
  90. {
  91. double a = Convert.ToInt32(textBox1.Text);
  92. double b = Convert.ToInt32(textBox2.Text);
  93. textBox3.Text = Convert.ToString(Math.Pow(a, 1/b));
  94. }
  95. }
  96. }
  97. }