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

What I have is below, and what I need to add are the Visual Basic statements as

ID: 3762278 • Letter: W

Question

What I have is below, and what I need to add are the Visual Basic statements as indicated by the comments.

Once that is done, execute the source code using the following 10 values. 45000, 22000, 6000, 100000, 57000, 1000, 90000, 12000, 6000, and 35000.

The minimum value should be 1000, and the maximum value should be 100000. The average value should be 37400.

___________________________________________________________________________________________________

Option Explicit On
Option Strict On
Module MinMaxSalary
   Sub Main()
        ' Declare a named constant for array size here
      

        ' Declare array here
      

   ' Use this integer variable as your loop index
        Dim loopIndex As Integer

        ' Use this variable to store the salary input by user
        Dim salary As Double

   ' Declare string version of salary here
   Dim salaryString As String      
      
        ' Use these variables to store the minimim and maximum values
        Dim min As Double
        Dim max As Double

        ' Use these variables to store the total and the average
        Dim total As Double
        Dim average As Double

        ' Write a loop to get salaries from user and assign to array
        For loopIndex = 0 To MAX_SALARIES - 1
            salaryString = InputBox$("Enter a salary: ")
            salary = Convert.ToDouble(salaryString)
            ' Assign value to array
          
        Next loopIndex
        ' Assign the first element in the array to be the minimum and the maximum
        min = salaries(0)
        max = salaries(0)
        ' Start out your total with the value of the first element in the array
        total = salaries(0)
        ' Write a loop here to access array values starting with numbers(1)
      
            ' Within the loop test for minimum and maximum salaries
          
            ' Also accumulate a total of all salaries
          
        ' Calculate the average of the 10 salaries
      

        ' Print the salaries stored in the salaries array
      
        ' Print the maximum value, minimum value, and average
      
   End Sub
End Module

Explanation / Answer

Option Explicit On
Option Strict On
Module MinMaxSalary
Sub Main()
' Declare a named constant for array size here
Const MAX_SALARIES As Double = 10
' Declare array here
Dim salaries(MAX_SALARIES) As Double
' Use this integer variable as your loop index
Dim loopIndex As Integer
' Use this variable to store the salary input by user
Dim salary As Double
' Declare string version of salary here
Dim salaryString As String
  
' Use these variables to store the minimum and maximum values
Dim min As Double
Dim max As Double
' Use these variables to store the total and the average
Dim total As Double
Dim average As Double
' Write a loop to get salaries from user and assign to array
For loopIndex = 0 To MAX_SALARIES - 1
salaryString = InputBox$("Enter a salary: ")
salary = Convert.ToDouble(salaryString)
' Assign value to array
salaries(loopIndex) = salary
Next loopIndex
' Assign the first element in the array to be the minimum and the maximum
min = salaries(0)
max = salaries(0)
' Start out your total with the value of the first element in the array
total = salaries(0)
' Write a loop here to access array values starting with numbers(1)
For loopIndex = 1 To MAX_SALARIES - 1
' Within the loop test for minimum and maximum salaries
           ' if current element of salaries array is less than min then
           ' update min to current element
If salaries(loopIndex) < min Then
min = salaries(loopIndex)
End If
           ' if current element of salaries array is greater than max then
           ' update max to current element
If salaries(loopIndex) > max Then
max = salaries(loopIndex)
End If
' Also accumulate a total of all salaries
           ' Add each element of salaries array to total
total = total + salaries(loopIndex)
Next loopIndex
' Calculate the average of the 10 salaries
       ' Total salary divided by number of salaries gives average salary
average = total / 10
' Print the salaries stored in the salaries array
For loopIndex = 0 To MAX_SALARIES - 1
Print salaries(loopIndex)
Next loopIndex
  
' Print the maximum value, minimum value, and average
Print "Maximum Salary is "
Print max
Print "Minimum Salary is "
Print min
Print "Average Salary is "
Print average
End Sub
End Module

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