Dim angle1 as decimal = 0
Dim radian1 as decimal = 0
Dim variabletype as String
Dim Hypotenuse as decimal = 0
Dim NumberofSides as integer = 0
Dim Numberofangles as integer = 0
Dim Numberofhypotenuse as integer = 0
Dim radian2 as decimal = 0
Console.WriteLine("Please select a variable you would like to enter. It could be a side or an angle of a right-angled triangle.")
Console.WriteLine("Enter 'S' for side or 'A' for angle to continue. It has to be in a capital letter")
variabletype = Console.ReadLine()
If variabletype <> "A" and variabletype <> "S" then
Console.WriteLine("Variable invalid, please try again")
loop until variabletype = "A" or variabletype = "S"
If Variabletype = "A" then
Numberofangles = Numberofangles + 1
If numberofangles = 1 then
console.WriteLine("What is the degree of the non-90-degree angle?")
angle1 = console.ReadLine()
If angle1 >= 90 or angle1 <= 0 then
Console.WriteLine("Angle invalid, please try again")
Loop until angle1 > 0 and angle1 < 90
If numberofangles = 2 then
console.WriteLine("What is the degree of the non-90-degree angle?")
angle2 = console.ReadLine()
If angle2 >= 90 or angle2 <= 0 then
Console.WriteLine("Angle invalid, please try again.")
If angle1 + angle2 = 90 then
Else if Angle1 + angle2 <> 90 then
Console.WriteLine("Two angles you've entered don't add up to 90, please try again")
If numberofangles > 2 then
Console.WriteLine("You can't have a right -angled triangle with more than 2 non-90 degree angles!")
If Variabletype = "S" then
Console.WriteLine("What is tpye of the side")
COnsole.WriteLine("It can either be the Hypotenuse or the right-angled side")
Console.WriteLine("Enter (H) for Hypotenuse or (S) for the right-angled side")
Sidetype = Console.ReadLine()
If sidetype <> "H" and sidetype <> "S" Then
Console.WriteLine("Side Tpye invalid")
Loop until sidetype = "H" or sidetype = "S"
Console.WriteLine("What is the length of the Hypotenuse?")
Numberofhypotenuse = Numberofhypotenuse + 1
If Numberofhypotenuse = 1 then
Hypotenuse = Console.ReadLine()
If numberofsides > 0 then
If Hypotenuse <= side1 then
Console.WriteLine("Are you sure about your data? Your side is greater or equal to your hypotenuse! You have to try again.")
Console.WriteLine("Hypotenuse invalid")
Console.WriteLine("Please try again")
Loop Until Hypotenuse > 0 and Hypotenuse > side1
If numberofhypotenuse > 1 then
Console.WriteLine("You do realise that you can't have two hypotenuses, right?")
Numberofsides = Numberofsides + 1
Console.WriteLine("Please enter the value of a side")
Side1 = console.ReadLine()
Console.WriteLine("Length invalid")
Console.WriteLine("Please try again")
If numberofhypotenuse > 0 then
If side1 >= hypotenuse then
Console.WriteLine("Are you sure? Your side is greater or equal to hypotenuse! Please try again.")
Else if Side1 < hypotenuse then
If Numberofhypotenuse = 0
If FFF = 1 or EEE = 3 then
Loop Until side1 > 0 and GGG = 1
If Numberofsides = 2 then
Side2 = console.ReadLine()
Console.WriteLine("Length invalid")
Console.WriteLine("Please try again")
If Numberofsides = 2 then
Elseif Numberofsides = 1 and Numberofhypotenuse = 1 then
Elseif Numberofangles = 1 and Numberofsides = 1 then
Console.WriteLine("Is the non-hypotenuse side you entered adjacent to the angle you entered ?")
Console.WriteLine("Enter 'YES' or 'NO'. They have to be in capital letters.")
If BBB <> "YES" and BBB <> "NO" then
console.WriteLine("Result invalid")
Loop until BBB = "YES" or BBB = "NO"
Elseif NumberofHypotenuse = 1 and Numberofangles = 1 then
console.WriteLine("I need more information. Please tell me another variable.")
Console.WriteLine("It could be a side or an angle")
Console.WriteLine("Enter 'S' or 'A', it has to be in capital letters")
loop until solution >= 1 and solution <= 5
Console.WriteLine("Calculation complete, here are the results...")
Radian1 = angle1 / 180 * pi
Radian2 = angle2 / 180 * pi
Hypotenuse =(side1 ^ 2 + side2 ^ 2) ^ 0.5
Radian1 = Math.Atan(Side1 / side2)
Radian2 = Math.Atan(Side2 / side1)
Side2 =(Hypotenuse ^ 2 - Side1 ^ 2) ^ 0.5
Radian1 = Math.Asin(Side1 / Hypotenuse)
Radian2 = Math.Asin(side2 / Hypotenuse)
Hypotenuse = side1 / Math.Cos(radian1)
Side2 =(Hypotenuse ^ 2 - Side1 ^ 2) ^ 0.5
Radian2 = Math.Asin(side1 / Hypotenuse)
Hypotenuse = side1 / math.Sin(radian1)
Side2 =(Hypotenuse ^ 2 - Side1 ^ 2) ^ 0.5
Radian2 = Math.Acos(side1 / hypotenuse)
side1 = Math.Sin(radian1) * Hypotenuse
Side2 = Math.Cos(radian1) * Hypotenuse
Radian2 = 90 / 180 * pi - radian1
Angle1 = radian1 * 180 / pi
Angle2 = radian2 * 180 / pi
Angle1 = math.Round(angle1, 2)
Angle2 = math.Round(angle2, 2)
Side1 = math.Round(side1, 2)
Side2 = math.Round(side2, 2)
Hypotenuse = math.Round(Hypotenuse, 2)
Console.WriteLine("Angle1 is " & angle1 & "°")
Console.WriteLine("Angle2 is " & angle2 & "°")
Console.WriteLine("Side1 is " & Side1)
Console.WriteLine("Side2 " & side2)
Console.WriteLine("Hypotenuse is " & hypotenuse)
Console.WriteLine("And you're welcome")