Monday, 9 July 2012

Simple Calculator

Make a simple calculator using operators.


using System;

class man
{
//dont ever take input from user in class body. it will occur error.

double a,b,result;
public void Accept()
{

Console.WriteLine("Enter 1st no");
a = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter 2nd no");
b = Convert.ToDouble(Console.ReadLine());

}
public void add()
{
result=a+b;
Console.WriteLine("addition is : "+result);
}
public void substract()
{
result=a-b;
Console.WriteLine("substraction is : "+result);
}
public void multiple()
{
result=a*b;
Console.WriteLine("multiple is : "+result);
}
public void devide()
{
result=a/b;
Console.WriteLine("division is : "+result);
}
}
class aditya

{
public static void Main()
{
man m=new man();
m.Accept();
m.add();
m.substract();
m.multiple();
m.devide();
}
}







No comments:

Post a Comment