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

Here is the question: In Visual Basic,Use a one-dimensional array to solve the f

ID: 3546187 • Letter: H

Question

Here is the question:


In Visual Basic,Use a one-dimensional array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 percent of $5000, or a total of $650. Write a program (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume 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


This needs to be a form application, as shown in the picture below:





Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $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 salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount): $200-299 $300-399 $400-499 $500-599 $600-699 $700-799 $800-899 $900-999 $1000 and over

Explanation / Answer

The following does what you described. You can modify it anyway you wish. You have the abilty to display each person's name and, sales and salary, if you desire.

Button one does the calculation; button 2 does the displaying of the peoples' ranking; button 3 clears the data from the textboxes, label and listbox.

Public Class Form1
Dim SalesList As New ArrayList()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Name As String = TextBox1.Text
Dim Sales As Double = TextBox2.Text
Dim Salary As Double
Salary = 200 + (Sales * 0.09)
Label1.Text = Format(Salary, "$#,###.00")
SalesList.Add(Name & " " & Sales & " " & Salary)
'MsgBox(SalesList(0))
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Str1 As String
Dim Range1 As Integer = 0
Dim Range2 As Integer = 0
Dim Range3 As Integer = 0
Dim Range4 As Integer = 0
Dim Range5 As Integer = 0
Dim Range6 As Integer = 0
Dim Range7 As Integer = 0
Dim Range8 As Integer = 0
Dim Range9 As Integer = 0
For i = 0 To SalesList.Count - 1
Str1 = SalesList(i)
Dim Arr() = Str1.Split(" ")
If Arr(2) >= 200 And Arr(2) < 300 Then
Range1 = Range1 + 1
ElseIf Arr(2) >= 300 And Arr(2) < 400 Then
Range2 = Range2 + 1
ElseIf Arr(2) >= 400 And Arr(2) < 500 Then
Range3 = Range3 + 1
ElseIf Arr(2) >= 500 And Arr(2) < 600 Then
Range4 = Range4 + 1
ElseIf Arr(2) >= 600 And Arr(2) < 700 Then
Range5 = Range5 + 1
ElseIf Arr(2) >= 700 And Arr(2) < 800 Then
Range6 = Range6 + 1
ElseIf Arr(2) >= 800 And Arr(2) < 900 Then
Range7 = Range7 + 1
ElseIf Arr(2) >= 900 And Arr(2) < 1000 Then
Range8 = Range8 + 1
ElseIf Arr(2) > 1000 Then
Range9 = Range9 + 1
End If
Next
If Range1 > 0 Then
ListBox1.Items.Add(Range1 & " salespersons in the $200 to $299 rank.'")
End If
If Range2 > 0 Then
ListBox1.Items.Add(Range2 & " salespersons in the $300 to $399 rank.'")
End If
If Range3 > 0 Then
ListBox1.Items.Add(Range3 & " salespersons in the $400 to $499 rank.'")
End If
If Range4 > 0 Then
ListBox1.Items.Add(Range4 & " salespersons in the $500 to $599 rank.'")
End If
If Range5 > 0 Then
ListBox1.Items.Add(Range5 & " salespersons in the $600 to $699 rank.'")
End If
If Range6 > 0 Then
ListBox1.Items.Add(Range6 & " salespersons in the $700 to $799 rank.'")
End If
If Range7 > 0 Then
ListBox1.Items.Add(Range7 & " salespersons in the $800 to $899 rank.'")
End If
If Range8 > 0 Then
ListBox1.Items.Add(Range8 & " salespersons in the $900 to $999 rank.'")
End If
If Range9 > 0 Then
ListBox1.Items.Add(Range9 & " salespersons in the above $1000 rank.")
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = " "
TextBox2.Text = " "
Label1.Text = " "
ListBox1.Items.Clear()
End Sub
End Class