C# Calculator
using System;
public class Program
{
public static void Main()
{
char Operation;
double SUM, DIFF, PROD, QUOT, first_Value, second_Value;
[Link]("Arithmetic Operation");
[Link]("\t[A] for \"Addition\"");
[Link]("\t[S] for \"Subtraction\"");
[Link]("\t[M] for \"Multiplication\"");
[Link]("\t[D] for \"Division\"");
[Link]("Select the Arithmetic Operation: ");
Operation = [Link]([Link]());
if (Operation != 'A' && Operation != 'a' && Operation != 'S' && Operation != 's' && Operation
!= 'M' && Operation != 'm' && Operation != 'D' && Operation != 'd')
{
[Link]("That Operation is not part of the choices");
}
else
[Link]("Enter the First Value: ");
first_Value = [Link]([Link]());
[Link]("Enter the Second Value: ");
second_Value = [Link]([Link]());
if (Operation == 'A' || Operation == 'a')
{
SUM = first_Value + second_Value;
[Link]("The Sum of the two value is: " + SUM);
}
else if (Operation == 'S' || Operation == 's')
{
DIFF = first_Value - second_Value;
[Link]("The Difference of the two value is: " + DIFF); }
else if (Operation == 'M' || Operation == 'm')
{
PROD = first_Value * second_Value;
[Link]("The Product of the two value is: " + PROD); }
else if (Operation == 'D' || Operation == 'd')
{
QUOT = first_Value / second_Value;
[Link]("The Quotient of the two value is: " + QUOT); }
[Link]();
}
}
Output
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Calculator
{
public partial class Form1 : Form
{
Double value = 0;
String operation = "";
bool operation_pressed = false;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button_Click(object sender, EventArgs e)
{
if (([Link] == "0")||(operation_pressed))
[Link]();
Button b = (Button)sender;
[Link] = [Link] + [Link];
}
private void button16_Click(object sender, EventArgs e)
{
[Link] = "0";
}
private void operator_click(object sender, EventArgs e)
{
Button b = (Button)sender;
operation = [Link];
value = [Link]([Link]);
operation_pressed = true;
}
private void button18_Click(object sender, EventArgs e)
{
switch (operation)
{
case "+":
[Link] = (value + [Link]([Link])).ToString();
break;
case "-":
[Link] = (value - [Link]([Link])).ToString();
break;
case "*":
[Link] = (value * [Link]([Link])).ToString();
break;
case "/":
[Link] = (value / [Link]([Link])).ToString();
break;
default:
break;
}//endswitch
operation_pressed = false; }
}
}
Output