Calculator Program By C#
Calculator Program By C#
- 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 Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public double getinput1()
- {
- string input1 = textBox1.Text;
- double inp1 = double.Parse(input1);
- return inp1;
- }
- public double getinput2()
- {
- string input2 = textBox2.Text;
- double inp2 = double.Parse(input2);
- return inp2;
- }
- public void Add()
- {
- double input1 = getinput1();
- double input2 = getinput2();
- double result = input1 + input2;
- textBox3.Text = result.ToString();
- }
- public void Sub()
- {
- double input1 = getinput1();
- double input2 = getinput2();
- double result = input1 - input2;
- textBox3.Text = result.ToString();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Add();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Sub();
- }
- public void Multiply()
- {
- double input1 = getinput1();
- double input2 = getinput2();
- double result = input1 * input2;
- textBox3.Text = result.ToString();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- Multiply();
- }
- public void Div()
- {
- double input1 = getinput1();
- double input2 = getinput2();
- double result = input1 / input2;
- textBox3.Text = result.ToString();
- }
- private void button4_Click(object sender, EventArgs e)
- {
- Div();
- }
- }
- }
No comments