SUMATORIA DE QUEBRADOS Y RAICES CON SWITCH
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace sw1
{
class Program
{
static void Main(string[] args)
{
int a;
double sum, b, c, d;
string aux;
do
{
Console.Clear();
Console.SetCursorPosition(12, 6);
Console.WriteLine("1.- DA EL VALOR DE N PARA 1/8+2/8+...+N/8 ");
Console.SetCursorPosition(12, 7);
Console.WriteLine("2.- DA EL VALOR DE N PARA 1^.5+2^.33+...+N^N+1");
Console.SetCursorPosition(12, 8);
Console.WriteLine("3.- SALIR");
Console.SetCursorPosition(8, 9);
Console.Write("QUE OPCION DESEAS ");
aux = Console.ReadLine();
a = int.Parse(aux);
Console.Clear();
switch (a)
{
case 1:
{
Console.SetCursorPosition(15, 10);
Console.Write("DAME EL VALOR DE N ");
aux=Console.ReadLine();
b = int.Parse(aux);
sum = 0;
for (c = 1; c <= b; c++)
{
sum = sum + c / 8;
}
Console.SetCursorPosition(15, 12);
Console.Write("EL VALOR DE LA SUMA ES " + sum);
Console.ReadKey();
break;
}
case 2:
{
Console.SetCursorPosition(15, 10);
Console.WriteLine("DAME EL VALOR DE N");
aux=Console.ReadLine();
b = int.Parse(aux);
sum = 0; d = 1;
for (c = 1; c <= b; c++)
{
sum = sum + Math.Pow(c, 1 / (d + 1));
}
Console.SetCursorPosition(15, 12);
Console.WriteLine("EL VALOR DE LA SUMA ES " + sum);
Console.ReadKey();
break;
}
case 3:
{
break;
}
default:
{
Console.SetCursorPosition(15, 10);
Console.WriteLine("SOLO SON 3 OPCIONES");
Console.ReadKey();
break;
}
}
}
while (a != 3);
}
}
}
No hay comentarios:
Publicar un comentario