We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, June 22, 2015

      Write a program to create ‘testMaths2’ class with x, y members. Accept the X, Y values from User, using Parameterized Constructor pass the values to x, y members and assign the values. Calculate the Addition, Subtraction values for x, y members. Show the Object content on a Console application.

         class TestMath2
    {
        int x, y;
        public TestMath2(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
        public void Add()
        {
            Console.WriteLine("Addition Result:" + (x + y));
        }
        public void Sub()
        {
            Console.WriteLine("Difference Result:" + (x - y));
        }
    }

    static void Main(string[] args)
    {
        int a, b;
        Console.WriteLine("Enter First number");
        a = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter Second number");
        b = int.Parse(Console.ReadLine());
        TestMath2 obj = new TestMath2(a, b);

        obj.Add();
        obj.Sub();
        Console.ReadLine();
    }
     output:

No comments: