Пример #1
0
        static void Main(string[] args)
        {
            calculator a = new calculator();


            Console.WriteLine(a.plus(2, 2, 2, 2, 2, 2, 2, 2));
        }
Пример #2
0
        static void Main(string[] args)
        {
            calculator c = new calculator();

            c.input();

            Console.WriteLine("Substraction is  :" + c.calculateSub());
            Console.WriteLine("addition is      :" + c.calculateAdd());
            Console.WriteLine("Multiplication is:" + c.calculateMult());
            Console.WriteLine("Divition is      :" + c.calculateDiv());
            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            calculator op = new calculator();
            string     Z  = "";

            do
            {
                Console.WriteLine("-------------------------------四则运算-------------------------");
                Console.WriteLine("");
                Console.WriteLine("请选择一种运算方法:1.加法 2.减法 3.乘法 4.除法 5.退出!");
                Z = Console.ReadLine();
                switch (Z)
                {
                case "1":
                    op.mathadd();
                    continue;

                case "2":
                    op.mathminus();
                    continue;

                case "3":
                    op.mathmultiply();
                    continue;

                case "4":
                    op.mathdivide();
                    continue;

                case "5":
                    op.result();
                    break;

                default:
                    Console.WriteLine("输入无效!");
                    continue;
                }
                break;
            }while (true);
        }
Пример #4
0
        static void Main(string[] args)
        {
            calculator x = new calculator();

            Console.WriteLine("Enter a function to perform\n 1 for addition  \n 2 for subtraction \n 3 for division \n 4 for mul");
            string input = Console.ReadLine();

            Console.WriteLine("write first number");
            double a, b, result;

            a = double.Parse(Console.ReadLine());
            Console.WriteLine("Enter 2nd number");
            b = double.Parse(Console.ReadLine());


            if (input == "1" || input == "one")
            {
                result = x.add(a, b);
                Console.WriteLine("{0}+{1}={2}", a, b, result);
            }

            if (input == "2" || input == "two")
            {
                result = x.sub(a, b);
                Console.WriteLine("{0}-{1}={2}", a, b, result);
            }

            if (input == "3" || input == "three")
            {
                result = x.divide(a, b);
                Console.WriteLine("{0}/{1}={2}", a, b, result);
            }

            if (input == "4" || input == "four")
            {
                result = x.mul(a, b);
                Console.WriteLine("{0}*{1}={2}", a, b, result);
            }
            Console.ReadLine();
        }
Пример #5
0
        static void Main(string[] args)
        {
            square sq1 = new square(2, 3);

            circle cr = new circle(2, 3, 4);

            cr.show();
            sq1.show();

            //Task_01
            Console.Write("***********\nTASK_01\n***********\n");
            square sq = new square(2, 3);

            Console.WriteLine(sq.ToString());

            Console.Write("\n\n***********\nTASK_02\n***********\n");
            Console.Write("\nEnter value 1: ");
            double a = double.Parse(Console.ReadLine());

            Console.Write("\nEnter value 2: ");
            double b = double.Parse(Console.ReadLine());

            //circle c=new circle(2,3,4);

            calculator cal = new calculator(a, b);

            int i = 1;

            while (i == 1)
            {
                Console.WriteLine("\nChoose any one operation:\n");
                Console.WriteLine("1: ADD\n");
                Console.WriteLine("2: SUBSTRACT\n");
                Console.WriteLine("3: MULTIPLY\n");
                Console.WriteLine("4: DIVIDE\n");
                Console.WriteLine("0: EXIT\n");

                int opt = int.Parse(Console.ReadLine());
                if (opt == 1)
                {
                    Console.WriteLine("\n" + a + "+" + b + "= " + cal.add());
                }
                else if (opt == 2)
                {
                    Console.WriteLine("\n" + a + "-" + b + "= " + cal.sub());
                }
                else if (opt == 3)
                {
                    Console.WriteLine("\n" + a + "*" + b + "= " + cal.mul());
                }
                else if (opt == 4)
                {
                    Console.WriteLine("\n" + a + "/" + b + "= " + cal.div());
                }
                else if (opt == 0)
                {
                    i = 0;
                }
            }

            //Console.WriteLine(c.ToString());

            Console.ReadKey();
        }