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

Using/creating 4 VB Classes, create a single Windows Form application to calcula

ID: 3678804 • Letter: U

Question

Using/creating 4 VB Classes, create a single Windows Form application to calculate the centroid and area of the 3 common shapes below: The centroid of a square or rectangle is located at a distance of 1/2 its height and 1/2 its base. The centroid of a right triangle is located at a distance of 1/3 its height and 1/3 its base. Create a Base (Parent) Class named clsShape containing 3 properties (Base, Height, Diameter) Create an additional 3 derived sub-classes named clsSquare, dsTriangle, clsCircle which Inherits the properties of the Base Class. For each of the derived classes, create 3 methods (functions) calculate the centroid (X and Y) and the Area In a Windows Form 1, create an instance (object) for each derived class named objSquare. objTriangle. objCircle For example: Dim objSquare as New clsSquare

Explanation / Answer

Hi i have written the code in VB for area calculation and sorry i couldn't make out the centroid calculation, Atleast this code below will help you to solve the area calculation.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Button1.Click

TextBox2.Text = 3.14 * TextBox1.Text

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Button2.Click   

   TextBox5.Text = TextBox3.Text * TextBox4.Text

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

Handles Button3.Click

Dim a As Integer = TextBox6.Text

Dim b As Integer = TextBox7.Text

Dim c As Integer = TextBox8.Text

Dim s As Double = (a + b + c) / 2

Dim findarea As Double = Math.Sqrt(s * (s - a) * (s - b) * (s - c))

TextBox9.Text = findarea

End Sub

End Class