Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
sir the final output of this program is must be like this

enter the first number:

enter the second number :

\\when you enter the two number, it occur this menu:

[a]add
[b]subtract
[c]multiply
[d]divide
what do you want to do:
\\put the letter there then the final answer must occur//

use the console c# language with arithmetic.class & program.cs

thanks hope to help me into this .
Posted
Updated 11-Aug-13 18:36pm
v2

C#
internal static class Arithematic
    {
        public static double Add(double a, double b)
        {
            return a + b;
        }
        public static double Divide(double a, double b)
        {
            return a / b;
        }
        public static double Multiply(double a, double b)
        {
            return a * b;
        }
        public static double Subtract(double a, double b)
        {
            return a - b;
        }
    }
 
Share this answer
 
Switch_Case_Example.html[^]

Check the link..hope it will help you..
 
Share this answer
 
The good thing I like about .net 4.0 is that we now can make extensions using static classes like above. We would use a slightly different approach and change double a to this double a and the resulting code would look like this
C#
internal static class Arithematic
    {
        public static double Multiply(this double a, double b)
        {
            return a * b;
        }
        public static double Divide(this double a, double b)
        {
            return a / b;
        }
        public static double Subtract(this double a, double b)
        {
            return a - b;
        }
        public static double Add(this double a, double b)
        {
            return a + b;
        }
    }

Now we don't have to use double d = Arithematic.Add(25.5, 25.5); to get the value of 51. We can simply call double result = ((double)25.5).Add(25.5);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900