martes, 19 de noviembre de 2013

SUMATORIA POTENCIA Y QUEBRADOS


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace SUMATORIADEQUEBRADOS
{
    class Program
    {
        static void Main(string[] args)
        {
            int opc, tab, con, sum,x,y,vi,vf;
             double x1, x2,n;
             string aux;
            do
            {
                Console.Clear();
            Console.SetCursorPosition(28, 5);
            Console.Write("M E N U");
            Console.SetCursorPosition(18, 7);
            Console.Write("1.- SUMATORIA 1^1 + 2^2 + ... + n^n");
            Console.SetCursorPosition(18, 8);
            Console.Write("2.- SUMATORIA 1/1 + 1/2 + ... + 1/n");
            Console.SetCursorPosition(18, 9);
            Console.Write("3.- SALIR");
            Console.SetCursorPosition(18, 11);
            Console.Write("QUE OPCION DESEAS  ");
            aux = Console.ReadLine();
            opc = int.Parse(aux);
                Console.Clear();
                switch (opc)
                {
                    case 1:
                        Console.SetCursorPosition(18, 5);
                        Console.Write("SUMATORIA 1^1 + 2^2 + ... + n^n");
                        Console.SetCursorPosition(18, 7);
                        Console.Write("DAME EL VALOR DE N  ");
                        aux = Console.ReadLine();
                        x = int.Parse(aux);
                        x1 = 0;
                        for (con = 1; con <= x; con++)
                        {
                            x1 = x1 + con*con;
                        }
                        Console.SetCursorPosition(18, 10);
                        Console.Write("EL RESULTADO DE LA SUMATORIA ES:   "+x1);
                        Console.ReadKey();
                        break;
                    case 2:
                        Console.SetCursorPosition(18, 5);
                        Console.Write("SUMATORIA DE 1/1+1/2+...+1/n");
                        Console.SetCursorPosition(18, 7);
                        Console.Write("DAME EL VALOR DE N  ");
                        aux = Console.ReadLine();
                        x1 = 0.0;
                        x=int.Parse(aux);
                        for (con = 1; con <= x; con++)
                        {
                            x1= x1 + 1.0/con;
                        }
                        Console.SetCursorPosition(10, 9);
                        Console.Write("EL VALOR DE LA SUMATORIA DE 1/1 + 1/2 + ... + 1/n  ES   " + x1);
                        Console.ReadKey();
                        break;
                    case 3:
                        break;
                    default:
                        Console.SetCursorPosition(18, 5);
                        Console.Write("SOLAMENTE SON 3 OPCIONES PON MAS ATENCION");
                        Console.ReadKey();
                        break;
                }
            }
            while (opc != 3);           
        }
    }
}

No hay comentarios:

Publicar un comentario