using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Calculator
{
public partial class Form1 : Form
{
private double num1, num2,ans;
public Form1()
{
InitializeComponent();
label4.Text = "0";
radioButton1.Checked = true;
}
private void button1_Click(object sender, EventArgs e)
{
ans = 0;
try
{
num1 = Convert.ToDouble(textBox1.Text);
num2 = Convert.ToDouble(textBox2.Text);
}
catch (Exception er1)
{
MessageBox.Show("Invalid Number!", "Hiru Cal ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (radioButton1.Checked == true)
ans = num1 + num2;
else if (radioButton2.Checked == true)
ans = num1 - num2;
else if (radioButton3.Checked == true)
{
try
{
ans = num1 / num2;
}
catch (DivideByZeroException err)
{
MessageBox.Show("ERRor"+err, "Hiru Cal ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
}
else if (radioButton4.Checked == true)
ans = num1 * num2;
label4.Text = ans.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
}
}
DOWNLOAD C# Calculator
Subscribe to:
Post Comments (Atom)
0 Responses so far.
Post a Comment