if you create an array of size 7, they are accessed as elemets 0-6, not 1-7. That's why you're getting the 'out of bounds' error.
You certainly CAN hard-code to add elements  - , but...
What happens if you want 30 elements? or a thousand? or 10,000?
There are two neat things you should check out. One is that an array can tell you how many elements it holds. From your example, you could say temp.length and get the number 7.
Then, you can write a loop that will run a certain number of times, and each time it could access a different element. So, you could write a loop that adds the 'current' value to a 'total' value. When the loop is done, your 'total' will have the sum of every element. you can then divide by the number of elements in the array.
By doing it this way, you can change the size of your array all you want, and you never have to touch the code that calculates the average.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors