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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private float a;
        private float b;
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            float sum = a + b;
            MessageBox.Show("The sum of a and b is: " + sum.ToString());
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (!float.TryParse(textBox1.Text, out a))
            {
                a = 0;
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (!float.TryParse(textBox2.Text, out b))
            {
                b = 0;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            float result = a - b;
            MessageBox.Show("The result of subtraction is: " + result.ToString());
        }

        private void button5_Click(object sender, EventArgs e)
        {
            float result = a * b;
            MessageBox.Show("The result of multiplication is: " + result.ToString());
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (b != 0)
            {
                float result = a / b;
                MessageBox.Show("The result of division is: " + result.ToString());
            }
            else
            {
                MessageBox.Show("Cannot divide by zero.");
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            float result = (float)Math.Sin(a);
            MessageBox.Show("The result of sin(a) is: " + result.ToString());
        }

        private void button7_Click(object sender, EventArgs e)
        {
            float result = (float)Math.Cos(a);
            MessageBox.Show("The result of cos(a) is: " + result.ToString());
        }

        private void button8_Click(object sender, EventArgs e)
        {
            float result = (float)Math.Tan(a);
            MessageBox.Show("The result of tan(a) is: " + result.ToString());
        }

        private void button10_Click(object sender, EventArgs e)
        {
            if (a >= 0)
            {
                float result = (float)Math.Sqrt(a);
                MessageBox.Show("The result of sqrt(a) is: " + result.ToString());
            }
            else
            {
                MessageBox.Show("SQRT invalid for negative numbers.");
            }
        }

        private void button11_Click(object sender, EventArgs e)
        {
            if (a > 0)
            {
                float result = (float)Math.Log10(a);
                MessageBox.Show("The result of log(a) is: " + result.ToString());
            }
            else
            {
                MessageBox.Show("LOG is undefined.");
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            if (a > 0)
            {
                float result = (float)Math.Log(a);
                MessageBox.Show("The result of ln(a) is: " + result.ToString());
            }
            else
            {
                MessageBox.Show("LN is undefined.");
            }
        }

        private void button13_Click(object sender, EventArgs e)
        {
            a = 0;
            b = 0;
            textBox1.Clear();
            textBox2.Clear();
        }

    }
}
