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

These instructions are very clear.
Have you written any part of this, yet?

No, I'm a beginner, I did something but not as required ... I want someone to help me ... thanks

Can you first make a Console App that says "Hello, World"?

yes

I know you need this for school and you might be late on this, but there are things you need to understand especially if you plan to write code in the future (next semester).

Can you then add a class to that code called Calculator?

using System;

namespace DW_402600
{
   public class Calculator
   {
      //calculator code goes here
   }

   class Program
   {
      static void Main(string[] args)
      {
         // code that uses calculator goes here
         // Calculator calc = new Calculator(3,4);
         // More code goes here to show results.
      }
   }
}

Edited 4 Years Ago by thines01: clarity

no :( is my first year. I am a little confused

Edited 4 Years Ago by dynw: n/a

OK, good.
So take that frame and add your methods to it.
There will be four methods and at LEAST one constructor in the calculator class.

you can do the whole code for me?
or even half?
I would be grateful

Edited 4 Years Ago by dynw: n/a

hi
can u post any code for your basic mathematical operation ...like (add,Sub etc ) so that i can help you..

Edited 4 Years Ago by kamilacbe: n/a

hi can someone help me .. say if my code is better?? not sure that I did good

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleCalculator
{
    class Program
    {
        static void Main(string[] args)
        {


            double op1, op2;
            Console.WriteLine("Dati op1: ");
            op1 = double.Parse(Console.ReadLine());
            Console.WriteLine("Dati op2: ");
            op2 = double.Parse(Console.ReadLine());
            Calculator c = new Calculator(op1, op2);

            c.Plus();
            Console.WriteLine(c.operand1 +"  "+ c.operatie +"  "+ c.operand2+ " =  "+c.rezultat);
            c.Minus();
            Console.WriteLine(c.operand1 + "  " + c.operatie + "  " + c.operand2 + " =  " + c.rezultat);
            c.Inmultit();
            Console.WriteLine(c.operand1 + "  " + c.operatie + "  " + c.operand2 + " =  " + c.rezultat);
            c.Impartit();
            Console.WriteLine(c.operand1 + "  " + c.operatie + "  " + c.operand2 + " =  " + c.rezultat);

            Console.WriteLine("Utilizare metode statice");

            Calculator.Plus(op1, op2);
            Calculator.Minus(op1, op2);
            Calculator.Inmultit(op1, op2);
            Calculator.Impartit(op1, op2);

            Console.ReadKey();
        }
    }

    public class Calculator
    {

        public double operand1;
        public double operand2;
        public double rezultat;
        public string operatie;
        public const double PI = 3.1415;


        public Calculator()
        {
        }

        public Calculator(double operand1, double operand2)
        {
            this.operand1 = operand1;
            this.operand2 = operand2;
        }

        public double Plus()
        {
            operatie = "+";
            return rezultat = operand1 + operand2;
        }
        public static double Plus(double operand1, double operand2)
        {
            double rezultat = operand1 + operand2;
            Console.WriteLine(operand1 + " + " + operand2 + " =  " + rezultat);
            return rezultat;
        }
        public double Minus()
        {
            operatie = "-";
            return rezultat = operand1 - operand2;
        }
        public static double Minus(double operand1, double operand2)
        {
            double rezultat = operand1 - operand2;
            Console.WriteLine(operand1 + " - " + operand2 + " =  " + rezultat);
            return rezultat;
        }
        public double Inmultit()
        {
            operatie = "*";
            return rezultat = operand1 * operand2;
        }
        public static double Inmultit(double operand1, double operand2)
        {
            double rezultat = operand1 * operand2;
            Console.WriteLine(operand1 + " * " + operand2 + " =  " + rezultat);
            return rezultat;
        }
        public double Impartit()
        {
            operatie = "/";
            return rezultat = operand1 / operand2;
        }
        public static double Impartit(double operand1, double operand2)
        {
            double rezultat = operand1 / operand2;
            Console.WriteLine(operand1 + " / " + operand2 + " =  " + rezultat);
            return rezultat;
        }
        public double Operand1
        {
            get
            {
                return operand1;
            }
            set
            {
                operand1 = value;
            }
        }

        public double Operand2
        {
            get
            {
                return operand2;
            }
            set
            {
                operand2 = value;
            }
        }


        public static string GetDisplayText(double rezultat)
        {
            return rezultat.ToString();
        }
    }
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

you Can Add this Class :

 class Calc
    {

            public const double pi = 3.14;

            // Method To ADD The Two Operands......
            public static double add(double op1, double op2)
            {
                double res = op1 + op2;
                return res;


            }
            // Method To Subtaract The Two Operands......
            public static double subtarct(double op1, double op2)
            {
                double res = op1 - op2;
                return res;


            }
            // Method To Multiply The Two Operands......
            public static double multi(double op1, double op2)
            {
                double res = op1 * op2;
                return res;


            }
            // Method To Divided The Two Operands......
            public static double div(double op1, double op2)
            {
                double res = op1 / op2;
                try
                {
                    return res;
                }
                catch (Exception ex)
                {
                    return 0;

                }



            }


    }

Edited 3 Years Ago by Nick Evan: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.