static private double leg(double c, double a)
return Math.Sqrt(c2 - a2);
static private double hyp(double a, double b)
return Math.Sqrt(a2 + b2);
public static void Main()
Console.WriteLine("If you would like to find the hypotenuse, press 2, if you would like to find the missing leg, press 1.");
string choice = Console.ReadLine();
Console.WriteLine("Please enter the leg of the triangle");
double input1 = double.Parse(Console.ReadLine());
Console.WriteLine("Please enter the hypotnuse");
double input2 = double.Parse(Console.ReadLine());
double output = leg(input2, input1);
Console.WriteLine("The missing leg is: " + output);
Console.WriteLine("Please enter the length of the legs.");
double input1 = double.Parse(Console.ReadLine());
double input2 = double.Parse(Console.ReadLine());
double output = hyp(input1, input2);
Console.WriteLine("The hypotenuse is: " + output);
Console.WriteLine("Would you like to run the program again? y/n");
string choice1 = Console.ReadLine();
if (choice1 == "y" || choice1 == "Y")