The issue is with the bottom of my code where I have to get the program to recite the entered values in reverse order. I think it might be something to do with the index?
Option Explicit On
Option Strict On
‘Author: Murray Spears
‘Date: October 12th 2012
‘Write a program that accepts five input values and stores them into an array.
‘Then display numbers in reverse order.
‘Then display the average number, and all numbers that are are above average.
Imports System
Module Values
Sub Main()
Dim Number(4) as Integer
Dim Average as Double = 0
Dim Index as integer
'
For Index = 0 to 4
Console.Write("Enter number: ")
Number(Index)=Convert.ToInt32(Console.Readline())
Next Index
'Figure out the average for all the entered values.
Average = (Number(0)+Number(1)+Number(2)+Number(3)+Number(4))/5
Console.Writeline("The average of the numbers is: " &Average)
Console.Write("Numbers that are greater than the average: ")
Index = 4
Do until Index = 0
If Number(Index) > Average then
Console.Writeline(Number(Index))
End If
Index -=1
Loop
Console.Writeline("Numbers in reverse order: ")
Index = 4
Do while Number(index) > 0
Console.Writeline(Number(Index))
Number(index) -= 1
Loop
End Sub
End Module
Use
Step -1to step backwards.