public static void Main()
        {
            _validator = new ConsoleInputValidator();

            // Task B
            var sideLength = _validator.GetIntegerInput("Input square side length: ", 0, int.MaxValue);
            var square     = new Square(sideLength);

            Console.WriteLine(square.ToString());

            // Task C
            var name   = _validator.GetStringInput("What is your name?");
            var age    = _validator.GetIntegerInput("How old are you?", 0, int.MaxValue);
            var person = new Person(name, age);

            Console.WriteLine(person.ToString());

            // Task D
            var radius = _validator.GetDoubleInput("Input radius: ", 0, double.MaxValue);
            var circle = new Circle(radius);
            var sphere = new Sphere(radius);

            Console.WriteLine($"Area= {circle.Area} Volume= {sphere.Volume} ");

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            // Task 1
            int    i;
            double suma = 0;

            double[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3 };
            for (i = 0; i < b.Length; i++)
            {
                double a;
                if (i % 2 == 0)
                {
                    a = i / 2d;
                }
                else
                {
                    a = i;
                }

                suma = Math.Pow(a - b[i], 2);
            }

            Console.WriteLine($"Sum = {suma}");

            // Task 2
            _validator = new ConsoleInputValidator();
            var n   = _validator.GetIntegerInput("Enter N = ", 0, int.MaxValue);
            var sum = 0;

            for (i = 0; i < n; i++)
            {
                sum += i;
                Console.Write($" {i} {sum} \n");
            }

            Console.ReadKey();
        }