hi can someone help me to make a calculator as required?
Create class Calculator. This class must contain the following features:

constant PI
constructor that accepts two integers, operand1 and operand2
method for writing values ​​and operand2 operand1
methods for calculating the four operations - addition, subtraction, division and multiplication that will return the result of operand1 and operand2 operation on values
static methods for these operations, which accepts parameters as operands
method that calculates the surface area of the circle diameter circle operand1.
Create a console application that instantiates object of class Calculator, call all the methods and write the result of calculation.
pls thanks
sorry for my bad english

My solution is :

class Calculator
    {
        private Double _num1;
        private Double _num2;

        public Double PI
        {
            get
            {
                return Math.PI;
            }
        }

        public Calculator(Double num1, Double num2)
        {
            this._num1 = num1;
            this._num2 = num2;
        }

        public void WriteNumber1()
        {
            Console.WriteLine(this._num1);
        }

        public void WriteNumber2()
        {
            Console.WriteLine(this._num2);
 }

        public Double Add()
        {
            return this._num1 + this._num2;
        }

        public Double Subtract()
        {
            return this._num1 - this._num2;
        }

        public Double Multiply()
        {
            return this._num1 * this._num2;
        }

        public Double Divide()
        {
            return this._num1 / this._num2;
        }

        public static Double Add(Double num1,Double num2)
        {
            return num1 + num2;
        }

        public static Double Subtract(Double num1, Double num2)
        {
            return num1 - num2;
        }

        public static Double Multiply(Double num1, Double num2)
        {
            return num1 * num2;
        }

        public static Double Divide(Double num1, Double num2)
        {
            return num1 / num2;
        }

        public static Double Cicrcle(Double r)
        {
            return Math.PI * 2 * r;
        }
}

Is this correct? What is missing? I am beginner .......

Edited 4 Years Ago by Ezzaral: code format

i dont know what i did wrong but code start with

class Calculator
{
private Double _num1;
private Double _num2;

You will need Main method to execute your code. Following is the simple example of Main method

public static void Main()
{
//TODO write your code here
}
This article has been dead for over six months. Start a new discussion instead.