static private double formula1(double x, double y)
return Math.Sqrt(x * x + y * y);
static private double formula2(double x2, double y2)
return Math.Sqrt(y2 * y2 - x2 * x2);
public static void Main()
while (random != "no" && random != "No")
Console.WriteLine("Do you want to find a missing leg or do you want to find the hypotenuse?");
Console.WriteLine("Enter 1 for a hypotenuse or please enter 2 for a missing leg.");
int sans = int.Parse(Console.ReadLine());
Console.WriteLine("Enter your first leg value:");
string a = Console.ReadLine();
if (double.TryParse(a, out a1))
Console.WriteLine("Enter your second leg value:");
string b = Console.ReadLine();
if (double.TryParse(b, out b1))
if (a != "" && b != "" && a1 > 0 && b1 > 0)
Console.WriteLine("Your hypotenuse is " + formula1(a1, b1));
Console.WriteLine("Press any other key to restart or e to exit.");
random = Console.ReadLine();
Console.WriteLine("Enter a value that is greater than 0. Press any value to restart the program or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a appropriate value. Press ENTER to restart or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a appropriate value. Press ENTER to restart or e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter your leg value:");
string c = Console.ReadLine();
if (double.TryParse(c, out c1))
Console.WriteLine("Please enter your hypotenuse value:");
string d = Console.ReadLine();
if (double.TryParse(d, out d1))
if (c != "" && d != "" && d1 > c1 && c1 > 0 && d1 > 0)
Console.WriteLine("Your missing leg is " + formula2(c1, d1));
Console.WriteLine("Press any other key to restart or press e to exit.");
random = Console.ReadLine();
else if (d1 <= 0 || c1 <= 0)
Console.WriteLine("Please enter a value greater than 0. Press 'enter' to restart or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a hypotenuse that is greater than the leg. Press ENTER to restart or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a valid value. Press ENTER to restart or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a valid value. Press ENTER to restart or press e to exit.");
random = Console.ReadLine();
Console.WriteLine("Please enter a valid value. Press ENTER to restart or press e to exit.");
random = Console.ReadLine();