Chapter 3 example 5: Create a function

Created a function with a loop that calculates the temp