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 .......

Recommended Answers

All 5 Replies

what are lines 1-7?

i dont know what i did wrong but code start with

class Calculator
{
private Double _num1;
private Double _num2;

Becha your code looks ok so what is your problem?

I got error message - Main method is missing

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
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.