Example #1
0
        static void Main(string[] args)
        {
            System.Collections.ArrayList myNumbers = new System.Collections.ArrayList();

            string userInput = "";

            Console.WriteLine("Enter any amount of numbers, press 'x' to finish: ");
            do
            {
                userInput = Console.ReadLine();
                myNumbers.Add(userInput);
            } while (userInput != "x");

            Console.WriteLine("Tack! Du matade in {0} nummer.", myNumbers.Count);

            Console.WriteLine("Enter operation '+' or '-' or '*' or '/': ");
            string op = Console.ReadLine();

            Calculator.Component.Calculator myCalculator = new Component.Calculator(); //skapar ny objekt i class?
            if (op == "+")
            {
                foreach (int i in myNumbers)
                {
                    Console.Write("{0} {1} ", i, op);

                    Console.Write(" = {3}", myCalculator.Add2(int i));
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number 1");
            int x = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter number 1");
            int y = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter operation + or -");
            string op = Console.ReadLine();

            Calculator.Component.Calculator myCalculator = new Component.Calculator();
            Console.WriteLine("{0} {1} {2} = {3}", x, y, op, myCalculator.Add(x, y));
        }
Example #3
0
        static void Main(string[] args)
        {
            //mata in 2 tal
            Console.WriteLine("Enter number 1");
            int x = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter number 2");
            int y = int.Parse(Console.ReadLine());

            Console.WriteLine("Enheter operation '+' or '-'");
            string op = Console.ReadLine();

            Calculator.Component.Calculator MyCalculator = new Component.Calculator();
            Console.WriteLine("{0} {1} {2} = {3}", x, op, y, MyCalculator.Add(x, y));

            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            //Mata in två tal
            //Gör en additionsberäkning och visa svaret
            Console.WriteLine("Enter number 1:");
            int x = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter number 2:");
            int y = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter operation '+' or '-'");
            string op = Console.ReadLine();

            //Nu vill vi göra beräkningen och visa resultatet
            Calculator.Component.Calculator MyCalculator = new Component.Calculator();
            Console.WriteLine("{0} {1} {2} = {3}", x, op, y, MyCalculator.Add(x, y));
        }