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

Could someone translate this vb code to structured english/gcode where appropria

ID: 3819334 • Letter: C

Question

Could someone translate this vb code to structured english/gcode where appropriate? (i.e Declare mailbox named etc..)

1.Public Class Form1
2. Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
3. 'gets all lines from the USStates text file into states array
4. Dim states() As String = IO.File.ReadAllLines("USStates.txt")
5. 'query to get all states areas of the US
6. Dim query = From state In states
7. Let data = state.Split(","c)
8. Let area = CDbl(data(2))
9. Select area
10. 'Calculating total area of US
11. Dim areasArray() As Double = query.ToArray
12. Dim totalArea As Double = areasArray.Sum
13. 'query to get the state's name and percentage of area
14. Dim qury = From state In states
15. Let data = state.Split(","c)
16. Let name = data(0)
17. Let area = CDbl(data(2))
18. Let percentage = area / totalArea
19. Let percent = FormatPercent(percentage)
20. Order By percentage Descending
21. Select name, percent
22. 'sets query data to the datasource property of grid view
23. dgvStates.DataSource = qury.Tolist
24. 'to disable default selection of grid view
25. dgvStates.CurrentCell = Nothing
26. 'sets colum names of data grid view
27. dgvStates.Columns("name").HeaderText = "State"
28. dgvStates.Columns("percent").HeaderText = "Percentage of Total Area"
29. End Sub
30.End Class

Explanation / Answer

public class Form1 {
    
    private void btnDisplay_Click(object sender, System.EventArgs e) {
        // gets all lines from the USStates text file into states array
        string[] states = IO.File.ReadAllLines("USStates.txt").Dim;
        query = From;
        state;
        states;
        data = ",".Split(c);
        area = double.Parse(data(2));
        switch (area) {
        }
        double[] areasArray = query.ToArray;
        double totalArea = areasArray.Sum;
        // query to get the state's name and percentage of area
        object qury = From;
        state;
        states;
        data = ",".Split(c);
        name = data(0);
        area = double.Parse(data(2));
        percentage = (area / totalArea);
        percent = FormatPercent(percentage);
        Order;
        By;
        percentage;
        Descending;
        switch (name) {
            case percent:
                // sets query data to the datasource property of grid view
                dgvStates.DataSource = qury.Tolist;
                // to disable default selection of grid view
                dgvStates.CurrentCell = null;
                dgvStates.Columns["name"].HeaderText = "State";
                dgvStates.Columns["percent"].HeaderText = "Percentage of Total Area";

break;

}

}

}

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