12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace calculator
- {
- public partial class MainForm : Form
- {
- public MainForm()
- {
- InitializeComponent();
- }
- private void btnCalculate_Click(object sender, EventArgs e)
- {
- double x, y, z;
- // Считываем данные
- try
- {
- x = double.Parse(tbInputX.Text);
- y = double.Parse(tbInputY.Text);
- z = double.Parse(tbInputZ.Text);
- } catch (FormatException)
- {
- MessageBox.Show("Убедитесь, что во всех полях указаны числа в правильном формате!");
- return;
- }
- // Вычисляем ответ
- double Output = 0.00d;
- try
- {
- Output += Math.Pow(2, Math.Pow(y, x));
- Output += Math.Pow(Math.Pow(3, x), y);
- Output -= (y * (Math.Atan(z) - Math.PI / 6)) / (Math.Abs(x) + 1 / (y * y + 1));
- } catch (DivideByZeroException)
- {
- MessageBox.Show("При вычислении ответа необходимо делить на 0!");
- return;
- }
- // Выводим ответ в lblAnswer
- lblAnswer.Visible = true;
- lblAnswer.Text = Convert.ToString(Output);
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- lblAnswer.Visible = false;
- }
- }
- }
|