You are on page 1of 1

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace aplicacion5
{
class Program
{
static void Main(string[] args)
{
double num1=0, cat1 = 0, cat2 = 0;
string rep = " ";
Console.WriteLine("debe ingresar el valor correspondiente de los lados
o catetos del triangulo para calcular la hipotenusa");
do
{
Console.WriteLine("ingrese el valor del primer cateto");
cat1 = double.Parse(Console.ReadLine());
Console.WriteLine("ingrese el valor del segundo cateto");
cat2 = double.Parse(Console.ReadLine());
Console.WriteLine("el valor ingresado del primer cateto es:" +" "
+cat1);
Console.WriteLine("el valor ingresado del segundo cateto es:" +" "
+cat2);
num1 = System.Math.Sqrt((cat1 * cat1) + (cat2 * cat2));
Console.WriteLine("seg�n el cateto 1: "+cat1+" y el cateto 2:
"+cat2+" el valor de la hipotenusa es: "+num1);
do
{
Console.WriteLine("desea calcular la hipotenusa de otro
triangulo?, digite si o no");
rep = Console.ReadLine();
} while (validartipo(rep) != true);
} while (rep == "Si" || rep == "si" || rep == "SI");

public static bool validartipo(string rep)


{
bool acepta = false;
if (rep == "Si" || rep == "si" || rep == "SI" || rep == "No" || rep ==
"no" || rep == "NO")
{
acepta = true;
}
else
{
Console.WriteLine("el dato no es correcto intente de nuevo");
}
return acepta;
}
}
}

You might also like