示例#1
0
 public static double Result(calculator k)
 {
     if (k.sign == "+")
     {
         return(k.Sum());
     }
     else if (k.sign == "-")
     {
         return(k.Difference());
     }
     else if (k.sign == "*")
     {
         return(k.Product());
     }
     else if (k.sign == "/")
     {
         return(k.Quotient());
     }
     else if (k.sign == "^")
     {
         return(k.Pow());
     }
     else if (k.sign == "%")
     {
         return(k.Root());
     }
     return(0);
 }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine(
                "#####################\n" +
                "## Suma        = + ##\n" +
                "## Różnica     = - ##\n" +
                "## Iloczyn     = * ##\n" +
                "## Iloraz      = / ##\n" +
                "## Potęga      = ^ ##\n" +
                "## Pierwiastek = % ##\n" +
                "#####################\n"
                );
            string sign = null, or = "T";
            double first = 0, second = 0;

            do
            {
                calculator k = new calculator(first, second, sign);
                k.Data();
                calculator.View(k);
                Console.Write("Czy kontynuować?(T/N): ");
                or = Console.ReadLine().ToUpper();
                Console.WriteLine();
            } while (or == "T");
        }
示例#3
0
 public static void View(calculator k)
 {
     if (k.sign != "%")
     {
         Console.WriteLine("{1} {3} {2} = {0}", calculator.Result(k), k.first, k.second, k.sign);
     }
     else
     {
         Console.WriteLine("Pierwiastek z {1} = {0}", calculator.Result(k), k.first);
     }
 }