static void Main(string[] args)
        {
            Console.WriteLine("Please input an integer: ");
            int intInput = Convert.ToInt32(Console.ReadLine());

            //instantiate MathOperations class
            MathOperations Squarednum = new MathOperations();

            //Assign user input to the Operand property
            Squarednum.Operand = intInput;

            //pass class instance to method; assign return to variable
            int SquareSolution = MathOperations.Squared(Squarednum);

            //write to console
            Console.WriteLine(intInput + " squared = " + SquareSolution);

            Console.ReadLine();


            //instantiate
            MathOperations Cubednum = new MathOperations();

            //assign user input to Operand property
            Cubednum.Operand = intInput;
            //pass class instance to method; assign return to variable
            int CubeSolution = MathOperations.Cubed(Cubednum);

            //write to console
            Console.WriteLine(intInput + " cubed = " + CubeSolution);
            Console.ReadLine();


            //instantiate
            MathOperations Fourthnum = new MathOperations();

            //assign user input to Operand property
            Fourthnum.Operand = intInput;
            //pass class instance to method; assign return to variable
            int FourthSolution = MathOperations.Fourth(Fourthnum);

            //write to console
            Console.WriteLine(intInput + "'s fourth root = " + FourthSolution);
            Console.ReadLine();
        }
Example #2
0
        public static void Main()
        {
            var maxElementInArray = MathOperations.FindMax(5, -1, 3, 2, 14, 2, 3);

            Console.WriteLine(maxElementInArray);

            var triangleArea = MathOperations.CalculateTriangleArea(3, 4, 5);

            Console.WriteLine(triangleArea);

            var numberInDigits = MathOperations.NumberToDigit(5);

            Console.WriteLine(numberInDigits);

            double pointX1 = 3;
            double pointY1 = -1;
            double pointX2 = 3;
            double pointY2 = 2.5;

            var distance = MathOperations.CalculateDistance(pointX1, pointY1, pointX2, pointY2);

            Console.WriteLine(distance);

            var horizontal = MathOperations.AreHorizontal(pointY1, pointY2);

            Console.WriteLine("Horizontal? -> {0}", horizontal);

            var vertical = MathOperations.AreVertical(pointX1, pointX2);

            Console.WriteLine("Vertical? -> {0}", vertical);

            MathOperations.PrintAsNumber(1.3, NumberFormatTypes.FixedPoint);
            MathOperations.PrintAsNumber(0.75, NumberFormatTypes.Percent);
            MathOperations.PrintAsNumber(2.30, NumberFormatTypes.RightAligned);

            Student peter  = new Student("Peter", "Ivanov", "Sofia", new DateTime(1992, 3, 17));
            Student stella = new Student("Stella", "Markova", "Vidin", new DateTime(1993, 3, 11), "gamer, high results");

            Console.WriteLine("Is {0} older than {1} ? -> {2}", peter.FirstName, stella.FirstName, peter.IsOlderThan(stella));
        }
        //Cubed method
        public static int Cubed(MathOperations num)
        {
            int cube = num.Operand * num.Operand * num.Operand;

            return(cube);
        }
        //4th root Method
        public static int Fourth(MathOperations num)
        {
            int fourth = num.Operand * num.Operand * num.Operand * num.Operand;

            return(fourth);
        }
        //squared method
        public static int Squared(MathOperations num)
        {
            int square = num.Operand * num.Operand;

            return(square);
        }