For the record, no, I don't expect anyone to 'do' my homework for me. :) I simply have some questions and would like a bit of nudging, I suppose. This question was covered before but I'm not quite following everything, so I figured I'd ask a few more questions.

The HW question is as follows:

"Use a one dimensional array to solve the following problem: A company pays its salesperson on a commission basis. The salesperson receives $200 per week, plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. 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) $200-$299
B) $300-$399
C) $400-$499
D) $500-$599
E) $600-$699
F) $700-$799
G) $800-$899
H) $900-$999
I) $1000 and over

And what I have so far (fleshing it out still) is:

Sub Main()

        Dim SalaryArray = New Integer(200, 300, 400, 500, 600, 700, 800, 900, 1000) {}
        Dim Range = New String("", "$200-$299", "$300-$399", "$400-$499", "$500-$599", "$600-$699", "$700-$799", "$800-$899", "$900-$999", "$1000 and above") {}
        Dim SalEntered As Integer
        Dim SalTotal As Integer


        Console.Write("Enter amount of sales grossed: (-1 to exit) ")
        SalEntered = Console.ReadLine
        Do Until SalEntered = -1
            SalTotal = SalEntered * 0.09 + 200

            Select Case SalTotal

                Case 200 To 299


                Case 300 To 399


                Case 400 To 499


                Case 500 To 599


                Case 600 To 699


                Case 700 To 799


                Case 800 To 899


                Case 900 To 999


                Case Else


            End Select

            ' limitations of case - can't round up/down, will return an F outside range, above 100 for instance

            Console.Write("Enter amount of sales grossed: (-1 to exit) ")
            SalEntered = Console.ReadLine()

        Loop

    End Sub

I suppose what's confusing me is the specific use of an array. I get the idea that I'm using the Select Case incorrectly; but again, I'm a bit confused. Any assistance at all would be appreciated.

Line #3 - Invalid array declaration. (Remove this line)

Line #4 - invalid array declaration

In vb.net array, lower bound (limit) is zero (0) and value 8 is an upper bound.

Dim Range(8) as Integer

>I get the idea that I'm using the Select Case incorrectly;

With each select case, increment the value of Range(index) variable.

eg.

....
      case 200 to 299
                Range(0)= Range(0) + 1
     .....
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.