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 Kalkulator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
label4.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
if(string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 harus diisi terlebih dahulu!");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a + b;
string d = string.Concat(this.textBox1.Text, " + ");
d = string.Concat(d, this.textBox2.Text);
this.label5.Text = d;
this.label4.Text = c.ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 harus diisi terlebih dahulu!");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a / b;
string d = string.Concat(this.textBox1.Text, " / ");
d = string.Concat(d, this.textBox2.Text);
this.label5.Text = d;
this.label4.Text = c.ToString();
}
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
label4.Text = "";
label5.Text = "";
}
private void label4_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 harus diisi terlebih dahulu!");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a * b;
string d = string.Concat(this.textBox1.Text, " x ");
d = string.Concat(d, this.textBox2.Text);
this.label5.Text = d;
this.label4.Text = c.ToString();
}
}
private void button4_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
{
MessageBox.Show("Angka 1 dan Angka 2 harus diisi terlebih dahulu!");
}
else
{
int a, b, c;
a = int.Parse(this.textBox1.Text);
b = int.Parse(this.textBox2.Text);
c = a - b;
string d = string.Concat(this.textBox1.Text, " - ");
d = string.Concat(d, this.textBox2.Text);
this.label5.Text = d;
this.label4.Text = c.ToString();
}
}
private void label5_Click(object sender, EventArgs e)
{
}
}
}