Complete the assignment below. Ensure that all of your assignment deliverables a
ID: 3595218 • Letter: C
Question
Complete the assignment below. Ensure that all of your assignment deliverables are attached before submitting your assignment.
Visual Basic .NET Application – Coding Exercise 3 (Exercise 13, Zack, 2016, p. 642)
For this coding exercise:
Create an application that can be used to calculate the cost of installing a fence around a rectangular area.Create the application, using the following names for the solution and project, respectively: Fence Solution and Fence Project. Save the application in the VB2015Chap11 folder.Use Windows to copy the Rectangle.vb file from the VB2015Chap11 folder to the Fence SolutionFence Project folder.Use the Project menu to add the Rectangle.vb class file to the project.Modify the class to use Double (rather than Integer) variables and properties.Add a method named GetPerimeter to the Rectangle class. The method should calculate and return the perimeter of a rectangle. To calculate the perimeter, the method will need to add together the length and width measurements, and then multiply the sum by 2.Create the interface shown in Figure 11-30 (zak, 2016). The image for the picture box is stored in the VB2015Chap11Fence.png file. Code the application and then test it appropriately. (Hint: Using 120 feet as the length, 75 feet as the width, and 10 as the cost per linear foot of fencing, the installation cost is $3,900.00.)
Explanation / Answer
Module FenceProject
Class Rectangle
Public length As Double ' Length of a Rectangle
Public breadth As Double ' Breadth of a Rectangle
Public Sub setLength(ByVal len As Double) ' Setting the length of a Rectangle
length = len
End Sub
Public Sub setBreadth(ByVal bre As Double) ' Setting the Breadth of a Rectangle
breadth = bre
End Sub
Public Function GetPerimeter() As Double 'Getting the Perimeter of a Rectangle
Return (2*(length + breadth))
End Function
End Class
Sub Main()
Dim Box1 As Rectangle = New Rectangle() ' Declare Box1 of type Rectangle
Dim Perimeter As Double ' Declare Perimeter variable to get perimeter value
Dim CostFence As Double ' Declare CostFence variable to get the cost of fencing
Box1.setLength(120)
Box1.setBreadth(75)
Perimeter=Box1.GetPerimeter()
CostFence= Perimeter * 10
Console.WriteLine("The length and breadth of the field is : ", Box1.length, " ", Box1.breadth)
Console.WriteLine("Perimeter of Rectangular Field is : ", Perimeter)
Console.WriteLine("The cost of fencing the filed is ", CostFence)
End Sub
End Module
OUTPUT:
The length and breadth of the field is : 120.00 75.00
Perimeter of Rectangular Field is : 390.00
The cost of fencing the filed is : 3900.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.