Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In VBA, Write a program that will be given all sides (a, b, c) of a triangle and

ID: 3788453 • Letter: I

Question

In VBA,

Write a program that will be given all sides (a, b, c) of a triangle and will test to see if these values realy do represent a triangle and if so, do they represent a right triangle. The program will ask the user to enter the three sides that will be tested using the following information. You should testthe numbers the user enters to see if they are appropriate (not zero or negative). Three numbers represent a triangle only if the largest side sum of the other two sides. It is a right triangle only if (largest sideY (sum of the squares of the other two sides). Include a Command Button in your document that executes the VBA code needed to solve the problem, You need ta hand in a print out of your document but also submit your document electronically following instructions given in class. Presentation requirements You need a complete solution: Problem Statement, Assumptions. Theory, Solution and Discussion The solution will be done in Word and must include: a flowchart of your program, a copy out of the computer code pasted on to the front of the document, a copy of your message boxes and a Command Button to use to run the program. The message boxes must include the entered values (a, b, c) and clearly state what was determined about the values (i,e, what is the largest side, do they form a triangle, is it a right triangle) Your flowchart and your computer code should be well documented Lhat means use appropriate comments in both to explain steps and define variables) Given Data (use the following sets af values to test your program) a 3, b 4, and c 5. 8, b 5, and c 2 7, b 3, and c m 6 1, b 2, and c 5

Explanation / Answer

Sub Getside()
Dim SideA As Double
Dim SideB As Double
Dim SideC As Double
Dim result As Double
Dim Msg As String
Msg = " Please Enter Side A for the Triangle"
Do
SideA = InputBox(Msg)
If IsNumeric(SideA) Then
If SideA > 0 Then Exit Do
End If
Msg = "number must be positive and greater than 0"
Loop
ActiveSheet.Range("B3").Value = SideA
Msg = " Please Enter Side B for the Triangle"
Do
SideB = InputBox(Msg)
If IsNumeric(SideB) Then
If SideB > 0 Then Exit Do
End If
Msg = "Please enter valid number"
Msg = Msg & vbNewLine
Msg = "number must be positive and greater than 0"
Loop
ActiveSheet.Range("C3").Value = SideB
Msg = " Please Enter Side C for the Triangle"
Do
SideC = InputBox(Msg)
If IsNumeric(SideC) Then
If SideC > 0 Then Exit Do
End If
Msg = "Please enter valid number"
Msg = Msg & vbNewLine
Msg = "number must be positive and greater than 0"
Loop
ActiveSheet.Range("D3").Value = SideC
Dim Largest As Integer
If SideA > SideB And SideA > SideC Then
Largest = SideA
ActiveSheet.Range("E3").Value = Largest
result = (SideB * SideB) + (SideC * SideC)
If (SideA * SideA) = result Then
Msg = Msg & vbNewLine
Msg = "YES, It is a right angled triangle!!!"
End If
Msg = Msg & vbNewLine
Msg = "NO, not a right angled triangle!!!"
End If
If SideB > SideA And SideB > SideC Then
Largest = SideB
ActiveSheet.Range("E3").Value = Largest
result = (SideA * SideA) + (SideC * SideC)
If (SideB * SideB) = result Then
Msg = Msg & vbNewLine
Msg = "YES, It is a right angled triangle!!!"
End If
Msg = Msg & vbNewLine
Msg = "NO, not a right angled triangle!!!"
End If
If SideC > SideA And SideC > SideB Then
Largest = SideC
ActiveSheet.Range("E3").Value = Largest
result = (SideA * SideA) + (SideB * SideB)
If (SideC * SideC) = result Then
Msg = Msg & vbNewLine
Msg = "YES, It is a right angled triangle!!!"
End If
Msg = Msg & vbNewLine
Msg = "NO, not a right angled triangle!!!"
End If
End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote