Question: Public Class frmRectangleArea Dim area As Decimal Dim numberOfRectangles As Integer Dim smallestRectangle As Decimal = 999999999 Private Sub btnCalculate_Click(sender As Object, e As EventArgs)

Public Class frmRectangleArea

Dim area As Decimal

Dim numberOfRectangles As Integer

Dim smallestRectangle As Decimal = 999999999

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

Dim length As Decimal = CDec(txtLength.Text)

Dim width As Decimal = CDec(txtWidth.Text)

area = width * length

numberOfRectangles = numberOfRectangles + 1

smallestRectangle = Math.Min(smallestRectangle, area)

txtArea.Text = area.ToString

txtNumberOfRectangles.Text = numberOfRectangles.ToString

txtSmallestRectangle.Text = smallestRectangle.ToString

txtLength.Select()

End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click

Me.Close()

End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

numberOfRectangles = 0

area = 0D

smallestRectangle = 999999999

txtLength.Text = ""

txtWidth.Text = ""

txtArea.Text = ""

txtNumberOfRectangles.Text = ""

txtSmallestRectangle.Text = ""

txtLength.Select()

End Sub

End Class

Question. In visual studio, analyzing this code, Comment on why SmallestRectangle is initialized with a large integer rather than 0 and Comment on how the min method works to return the smallest rectangle.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!