Op Avanzadas- Enteros C#

/// <summary>
        /// Este metodo realizaremos la operacion de potenciar
        /// </summary>
        /// <param name="a">Es una variable de tipo int, la variable no puede ser null</param>
        /// <param name="b">Es una variable de tipo int, la variable no puede ser null, y debe ser                        diferente de 0</param>
public static string PotenciaEntero(double x, double y)
        {
            double potencia = Math.Pow(x, y);
            string res = potencia.ToString();
            if (res.Contains(","))
            {
                int numEntero = int.Parse(res.Split(',')[0]);
                double numDecimal = double.Parse("0," + res.Split(',')[1]);
                string pot = "\nParte entera: " + numEntero + "\nParte decimal: " + numDecimal;
                return pot;
            }
            else
            {
                return res;
            }
        }

        public static string RadicacionEntero(double x, double y)
        {
            if (x < 0)
            {
                throw new SystemException();
            }
            else
            {
                double radicacion = Math.Pow(x, (1 / y));
                string res = radicacion.ToString();
                if (res.Contains(","))
                {
                    int numEntero = int.Parse(res.Split(',')[0]);
                    double numDecimal = double.Parse("0," + res.Split(',')[1]);
                    string rad = "\nParte entera: " + numEntero + "\nParte decimal: " + numDecimal;
                    return rad;
                }
                else
                {
                    return res;
                }
            }
        }

        public static double PotenciaDiezEntero(int x)
        {
            double pot10 = Math.Pow(10, x);
            return pot10;
        }

        }

No hay comentarios:

Publicar un comentario