1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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 RadioCalculator
- {
- public partial class CalculatorMain : Form
- {
- public CalculatorMain()
- {
- InitializeComponent();
- }
- private void CalcMainLoad(object sender, EventArgs e)
- {
- lblAnswer.Visible = false;
- }
- private void btnCalculate_Click(object sender, EventArgs e)
- {
- // Считываем значения, проверяем правильность
- float x, y, z, Output;
- try
- {
- x = float.Parse(tbInputX.Text);
- y = float.Parse(tbInputY.Text);
- z = float.Parse(tbInputZ.Text);
- }
- catch (FormatException)
- {
- MessageBox.Show("Убедитесь, что во всех полях указаны числа в правильном формате!");
- return;
- }
- // Вычисляем ответ
- // Значение функции f(x)
- float FunctionOutput;
- try
- {
- if (rbFunctionSh.Checked)
- {
- FunctionOutput = MathF.Sinh(x);
- }
- else if (rbFunctionPow2.Checked)
- {
- FunctionOutput = (float)Math.Pow(x, 2);
- }
- else
- {
- FunctionOutput = (float)Math.Pow(Math.E, x);
- }
- // Значение выражения
- Output = Math.Min(FunctionOutput + y, y - z) / Math.Max(FunctionOutput, y);
- } catch (Exception ex)
- {
- MessageBox.Show($"Возникла ошибка при вычислении выражения! ({ex.Message})");
- return;
- }
-
- // Записываем ответ в надпись
- lblAnswer.Visible = true;
- lblAnswer.Text = Convert.ToString(Output);
- }
- }
- }
|