helo..i have a problem with my system.. i have try many time and i cannot solve the problem..here is my question

Use one dimensional array to solve the following problem: A company pays its salesperson on a commission basis. The salesperson receives RM200 per week, plus 9% of their gross sales for that week. For example, a salesperson who grosses RM5000 in sales in a week receives RM200 plus 9% of RM5000, or a total of RM650. Write a program (using an array of counters) that determines how many of the salesperson earned salaries in each of the following ranges (assumes that each salesperson’s salary is truncated to an integer amount):
A) RM200-RM299
B) RM300-RM399
C) RM400-RM499
D) RM500-RM599
E) RM600-RM699
F) RM700-RM799
G) RM800-RM899
H) RM900-RM999
I) RM1000 and over

please help me.. the output should be like attachment

You actually need three different arrays for this solution. The first will hold the salary ranges that you mentioned above. The second will hold the earnings of each salesperson. The last array will keep track of how many salaries fell into each range. Once the arrays are filled, you will display the "salary ranges" array and the "each range" array into the list box.

i understand what u say but i did not know how to use array on my code. here is my full code. hope u can help me to use array on my code.

Public Class Form1

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

        Dim salary() As Integer = {200, 300, 400, 500, 600, 700, 800, 900, 1000}
        Dim range() As String = _
            {"", "$200-$299", "$300-$399", "$400-$499", "$500-$599", "$600-$699", "$700-$799", "$800-$899", "$900-$999", "$1000 and above"}
        Dim x As Integer = 0
        Dim searchFor As Double
        Dim o As String = "{0, -15}{1, 10}"


        TextBox2.Text = 0.09 * TextBox1.Text + 200
        searchFor = Double.Parse(Me.TextBox2.Text)

        Do While x < salary.Length AndAlso searchFor >= salary(x)
            x = x + 1
        Loop

        ListView1.Items.Add(String.Format(o, "Salary Range :   ", "Total"))
        ListView1.Items.Add(String.Format(o, Convert.ToString(range(x)), ""))

    End Sub

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

    End Sub

End Class

while i use array on my code there was wrong output..then i use this code but this code no using array..but i suppose to use array on my code..

Public Class Form1

    Sub forOut()

        Dim x As Integer = 0
        Dim o As String = "{0, -15}{1, 10}"

        ListView1.Items.Add(String.Format(o, "Salary Range :     ", "Total"))
        ListView1.Items.Add(String.Format(o, "$200-$299:         ", Convert.ToString(Label4.Text)))
        ListView1.Items.Add(String.Format(o, "$300-$399:         ", Convert.ToString(Label6.Text)))
        ListView1.Items.Add(String.Format(o, "$400-$499:         ", Convert.ToString(Label7.Text)))
        ListView1.Items.Add(String.Format(o, "$500-$599:         ", Convert.ToString(Label8.Text)))
        ListView1.Items.Add(String.Format(o, "$600-$699:         ", Convert.ToString(Label10.Text)))
        ListView1.Items.Add(String.Format(o, "$700-$799:         ", Convert.ToString(Label11.Text)))
        ListView1.Items.Add(String.Format(o, "$800-$899:         ", Convert.ToString(Label12.Text)))
        ListView1.Items.Add(String.Format(o, "$900 and above:", Convert.ToString(Label13.Text)))

    End Sub

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

        totsalary.Text = entsale.Text * 0.09 + 200

        If totsalary.Text >= 200 And totsalary.Text < 300 Then
            Label4.Text = Label4.Text + 1
        ElseIf totsalary.Text >= 300 And totsalary.Text < 400 Then
            Label6.Text = Label6.Text + 1
        ElseIf totsalary.Text >= 400 And totsalary.Text < 500 Then
            Label7.Text = Label7.Text + 1
        ElseIf totsalary.Text >= 500 And totsalary.Text < 600 Then
            Label8.Text = Label8.Text + 1
        ElseIf totsalary.Text >= 600 And totsalary.Text < 700 Then
            Label10.Text = Label10.Text + 1
        ElseIf totsalary.Text >= 700 And totsalary.Text < 800 Then
            Label11.Text = Label11.Text + 1
        ElseIf totsalary.Text >= 800 And totsalary.Text < 900 Then
            Label12.Text = Label12.Text + 1
        ElseIf totsalary.Text >= 900 Then
            Label13.Text = Label13.Text + 1
        End If
        entsale.Text = ""

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListView1.Items.Clear()
        forOut()
    End Sub
End Class

In order to use an array you are going to have to build your salary() as you go. So, you will first declare

Dim salary() as Integer

.
Each time the user enters a salary, you will send it to your salary() array.

ReDim Preserve salary(x)
salary(x) = TextBox2.Text = 0.09 * TextBox1.Text + 200
x = x + 1

You can then use a If...Else or a Select Case statement to place each value from salary() into a third array which
will hold the totals from each range. When all of this is done, create a loop to display all of the values from range() and the totals array in the list box.
I hope that was not to confusing.

thanks my friend.. it work..now i can use array in my code :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.