I am trying to learn C#. There is one example of console calculator I am trying to do and I did something but not everything.....

Question is:

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.

I did something but I got error message of course - could you please tell me what I did wrong and is there any other way to do this?

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; } }

This post has been edited by **macosxnerd101**: 04 April 2012 - 07:55 AM

Reason for edit:: Please use code tags