Hi,
I have been working on this all weekend and can't figure out what I am doing wrong. The objective is to collect 3 numbers from the user then display to them the numbers they entered, the lowest number entered, the highest number entered, the total, and the average. Can someone review this and tell me what I am not getting? Thanks in advance!
Module Module1
Const SIZE As Integer = 2
Sub Main()
Dim tempArray() As Integer = New Integer(SIZE) {}
Dim entries() As Integer = New Integer(SIZE) {}
Dim lowest, highest, total, average As Integer
entries = GetEntries(tempArray)
Message(entries)
lowest = GetLowest(entries, SIZE)
highest = GetHighest(entries, SIZE)
total = GetTotal(entries, SIZE)
average = GetAverage(entries, total, SIZE)
Console.ReadLine()
End Sub
Function GetEntries(ByVal tempArray() As Integer) As Integer()
For count = 0 To 2
Console.WriteLine(" Please enter a whole number:")
tempArray(count) = Console.ReadLine()
Next
Return tempArray
End Function
Sub Message(ByVal tempArray() As Integer)
Console.WriteLine("Here are your entries: ")
For count = 0 To 2
Console.WriteLine(tempArray(count))
Next
End Sub
Function GetLowest(ByVal entries() As Integer, ByVal SIZE As Integer) As Integer
Dim index As Integer
Dim lowest As Integer = 0
lowest = entries(0)
For index = 0 To entries(SIZE)
If entries(index) < lowest Then
Console.WriteLine()
Console.WriteLine("This is the LOWEST number entered: " + CStr(entries(index)))
End If
Next
End Function
Function GetHighest(ByVal entries() As Integer, ByRef SIZE As Integer) As Integer
Dim index As Integer
Dim highest As Integer
highest = entries(0)
For index = 0 To entries(SIZE)
If entries(index) > highest Then
Console.WriteLine()
Console.WriteLine("This is the LOWEST number entered: " + CStr(entries(index)))
highest = entries(index)
End If
Next
End Function
Function GetTotal(ByVal entries() As Integer, ByVal SIZE As Integer) As Integer
Dim index As Integer = 0
Dim total As Integer = 0
total = entries(0)
For index = 0 To entries(SIZE)
If entries(index) = +total Then
Console.WriteLine()
Console.WriteLine("This is the TOTAL for all entries: " + CStr(entries(index)))
End If
Next
End Function
Function GetAverage(ByVal entries() As Integer, ByVal total As Integer, ByVal SIZE As Integer) As Integer
Dim index As Integer = 0
Dim average As Integer = 0
average = entries(0)
For index = 0 To entries(SIZE)
If entries(index) = average Then
Console.WriteLine()
Console.WriteLine("This is the AVERAGE of all numbers entered: " + CStr(entries(index)))
average = total / (SIZE)
Console.ReadLine()
End If
Next
End Function
End Module