lunes, 18 de noviembre de 2013

MENU FORMULA GRAL Y SUM DEL 1 A LA N



MENU CON LA FORMULA GRAL Y SUMATORIA DEL 1 A LA N

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace MENUFORMGRALYSUMATORIA
{
    class Program
    {
        static void Main(string[] args)
        {
             int opc, tab, con, sum,x,y,vi,vf;
             double x1, x2;
             string aux;
            do
            {
                Console.Clear();
            Console.SetCursorPosition(18, 5);
            Console.Write("M E N U");
       Console.SetCursorPosition(18, 7);
             Console.Write("1.- FORMULA GRAL");
            Console.SetCursorPosition(18, 8);
            Console.Write("2.- SUMATORIA 1+2+...+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("FORMULA GRAL.");
                        Console.SetCursorPosition(18, 7);
                        Console.Write("DAME EL VALOR DE A  ");
                        aux = Console.ReadLine();
                        x = int.Parse(aux);
                        Console.SetCursorPosition(18, 8);
                        Console.Write("DAME EL VALOR DE B  ");
                        aux = Console.ReadLine();
                        y = int.Parse(aux);
                        Console.SetCursorPosition(18, 9);
                        Console.Write("DAME EL VALOR DE C  ");
                        aux = Console.ReadLine();
                        vi = int.Parse(aux);
                        vf = y * y - 4 * x * vi;
                        if (vf > 0)
                        {
                            Console.SetCursorPosition(18, 11);
                            Console.Write("RAICES REALES");
                        }
                        else
                        {
                            Console.SetCursorPosition(18, 11);
                            Console.Write("RAICES IMAGINARIAS");
                            vf = vf * -1;
                        }
                        x1 = (-y + Math.Sqrt(vf)) / (2 * x);
                        x2 = (-y - Math.Sqrt(vf)) / (2 * x);
                        Console.SetCursorPosition(18, 12);
                        Console.Write("X1 = " + x1);
                        Console.SetCursorPosition(18, 13);
                        Console.Write("X2 = " + x2);
                        Console.ReadKey();
                        break;
                    case 2:
                        Console.SetCursorPosition(18, 5);
                        Console.Write("SUMATORIA DE 1+2+...+n");
                        Console.SetCursorPosition(18, 7);
                        Console.Write("DAME EL VALOR DE N  ");
                        aux = Console.ReadLine();
                        x1 = 0;
                        x = int.Parse(aux);
                        for (con = 1; con <= x; con++)
                        {
                            x1=x1 +  con;
                        }
                        Console.SetCursorPosition(18, 9);
                        Console.Write("EL VALOR DE LA SUMATORIA DE 1+2+...+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