Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Created by SharpDevelop.
- * User: Admin
- * Date: 12.1.2022 г.
- * Time: 13:02
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- namespace drobi
- {
- /// <summary>
- /// Description of MainForm.
- /// </summary>
- public partial class MainForm : Form
- {
- public MainForm()
- {
- //
- // The InitializeComponent() call is required for Windows Forms designer support.
- //
- InitializeComponent();
- //
- // TODO: Add constructor code after the InitializeComponent() call.
- //
- }
- void RadioButtonPlusCheckedChanged(object sender, EventArgs e)
- {
- labelSign.Text = "+";
- }
- void RadioButtonMinusCheckedChanged(object sender, EventArgs e)
- {
- labelSign.Text = "-";
- }
- void RadioButtonPoCheckedChanged(object sender, EventArgs e)
- {
- labelSign.Text = "*";
- }
- void RadioButtonDelCheckedChanged(object sender, EventArgs e)
- {
- labelSign.Text = "/";
- }
- void ButtonCalculateClick(object sender, EventArgs e)
- {
- int a = 0;
- int b = 0;
- int c = 0;
- int d = 0;
- int x, y;
- try
- {
- a = int.Parse(textBoxA.Text);
- b = int.Parse(textBoxB.Text);
- c = int.Parse(textBoxC.Text);
- d = int.Parse(textBoxD.Text);
- }
- catch
- {
- MessageBox.Show("Некоректни входни данни");
- return;
- }
- if (labelSign.Text == "?")
- {
- MessageBox.Show("Изберете действие");
- return;
- }
- if (labelSign.Text == "+")
- {
- x = a * d + b * c;
- y = b * d;
- labelX.Text = x.ToString();
- labelY.Text = y.ToString();
- }
- else if (labelSign.Text == "-")
- {
- x = a * d - b * c;
- y = b * d;
- labelX.Text = x.ToString();
- labelY.Text = y.ToString();
- }
- else if (labelSign.Text == "*")
- {
- x = a * c;
- y = b * d;
- labelX.Text = x.ToString();
- labelY.Text = y.ToString();
- }
- else if (labelSign.Text == "/")
- {
- x = a * d;
- y = b * c;
- labelX.Text = x.ToString();
- labelY.Text = y.ToString();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement