Reference no: EM13499045
Write lines of code as instructed in Steps (a) through (e) to fill in the missing lines in the following program:
Structure Appearance
Dim height As Double 'inches
Dim weight As Double 'pounds
End Structure
Structure Person
Dim name As String
Dim stats As Appearance
End Structure
Private Sub BtnDisplay_Click(...) Handles btnDisplay.Click
Dim person1, Person2 As Person
a. (a) Give person1 the name Michael
b. (b) Set Michael's height and weight to 71 and 190, respectively
c. (c) Give person2 the name Jacob
d. (d) Set Jacob's height and weight to 70 and 175, respectively
e. (e) If one person is both taller and heavier than the other, display a sentence of the form
"[name of bigger person] is bigger than [name of smaller person]."
In exercises 15 through 18 describe the output that results from clicking on the button. The programs use the file Cities.txt that contains information about the 25 largest cities in the United States. Each record of the file has four fields - name, state, population in 2000 (in 100,000s), and population in 2010 (in 100,000s). The first four lines in the file are as follows:
New York, NY,80.1,82.7
Los Angeles,CA,36.9,38.84
Chicago,IL,29.0,28.7
Houston,TX,19.5,22.4
Assume that each program contains the following code:
Structure City
Dim name As String
Dim state As String
Dim pop2000 As Double
Dim pop2010 As Double
End Structure
Dim cities() As City
Private Sub frmCities_Load(...) Handles Me.Load
'Place the data for eaech city into the array cities
Dim cityRecords() = IO.File.ReadAllLines("Cities.txt")
'Use the array cityRecords to populate the array cities.
Dim n = cityRecords.Count = 1
ReDim cities(n)
Dim line As String 'holds data for a single city
Dim data() As String
For i As Integer = 0 to n
line = cityRecords(i)
data = line.Split(","c)
cities(i).name = data(0)
cities(i).state = data(1)
cities(i).pop2000 = CDbl(data(2))
cities(i).pop2010 = CDbl(data(3))
Next
End Sub
HERE ARE THE QUESTIONS!
16. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
dim query = From cty In Cities
Where city.state = "TX"
Let growth = (cty.pop2010 - cty.pop2000) / cty.pop2000
Order By Growth Descending
Select cty.name, cty.state, growth
For Each cty In query
1stOutput.Items.Add(cty.name & ", " & cty.state)
Next
1stOutput.Items.Add("Greatest growth: " &
FormatPercent (query.First.growth))
End Sub
18. Private Sub btnDisplay_Click(...) Handles btn.Display.Click
Dim query = From cty In cities
Order by cty.pop2010 Descending
Select cty.pop2010
Dim pops() As Double = query.toArray
ReDim Preserve pops(9)
txtOutput.Text = FormatNumber(100000 * pops.Sum, 0)
End Sub